I need to create a text file on external STORAGE of an android mobile phone:
i use this code:
string fileName = Path.Combine(Android.OS.Environment.ExternalStorageDirectory.AbsolutePath, "Test.txt");
And get thi error:
Android does not contain a definition for 'OS'
TAHNKS to every one

Delpin Susai RajRank #53 · 29.5K reputationPosted Feb 2, 2024, 8:09 AM EST
Your trying to get path from Android.OS.Environment Change to iOS path
Riccardo Daria84 reputationPosted Feb 2, 2024, 11:10 AM EST
I don't understand,
please, I need write on external STORAGE on android mobile phone using XAMARIN
THANKS
Tuhin PaulRank #7 · 71.9K reputationPosted Feb 3, 2024, 4:12 AM EST
I'll need more information to provide the better instructions:
1. Android Version and Development Environment:
2. Permission Handling:
AndroidManifest.xmlfile? This is mandatory for Android 10 and laterRiccardo Daria84 reputationPosted Feb 5, 2024, 3:00 AM EST
OK dear Tuhin Paul,
Android Version: 9;
Language used: C# in XAMARIN
i use this code:
string fileName = Path.Combine(Android.OS.Environment.ExternalStorageDirectory.AbsolutePath, "Test.txt"); //Pass the filepath and filename to the StreamWriter Constructor StreamWriter sw = new StreamWriter(fileName); //Write a line of text sw.WriteLine("Hello World!!"); //Write a second line of text sw.WriteLine("From the StreamWriter class"); //Close the file sw.Close();