I m sure there is something really obvious I am missing on this but how can you create and store a file with monodroid. I am talking about something simple
private void Save(int rating)
{
try
{
var externalStorageDirectory = Environment.GetExternalStoragePublicDirectory(Environment.DirectoryDcim);
File.WriteAllText(Path.Combine(externalStorageDirectory.Path,"mycsv.csv"),
string.Format("{0},{1},{2},"+ System.Environment.NewLine, _name, _model, rating));
}
catch(Exception ex)
{
Console.WriteLine("Problem saving", ex.Message, ex.StackTrace);
}
}
When I try the above, every possible directory I could think of I get a DirectoryNotFoundException. I’m sure this is something trivial but a quick browse is not getting me any results and I m sure there are better ways than hardcoding the path.
Also, if File.WriteAllText is not the way to go, when creating files that should be consumed externally, I’m all ears.
Thanks
var fileName = Android.OS.Environment.ExternalStorageDirectory + Java.IO.File.Separator + "MyFile.csv";This gets you the folder of the External Storage, this is usually the MicroSD card.
And then just write your file to the
FileStream: