Riccardo Daria

Riccardo Daria

  • 1.7k
  • 74
  • 5k

SAVE test file on external Storage of ANDROID Mobile PHONE XAMARIN c#

Feb 8 2024 4:45 PM

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();

And get this error:

Android does not contain a definition for 'OS'

THANKS to everyone


Answers (1)