You write files in Xamarin pretty much as you would any file in C#.
You can use the namespace
Android.OS.Environment
to give you the system folders e.g. to get the path to the SD card you would use
Android.OS.Environment.ExternalStorageDirectory
Here is an example of saving an image to the SD card.
private string SaveToSd()
{
var folder = Android.OS.Environment.ExternalStorageDirectory + Java.IO.File.Separator + "ImageFolder";
var extFileName = folder +
Java.IO.File.Separator +
Guid.NewGuid() + ".png";
try
{
if (!Directory.Exists(folder))
Directory.CreateDirectory(folder);
using (var fs = new FileStream(extFileName, FileMode.OpenOrCreate))
{
return extFileName;
}
}
catch
{
RunOnUiThread(() =>
{
var builder = new AlertDialog.Builder(this);
builder.SetMessage("Saving image went wrong");
builder.SetTitle("Unable to save image");
builder.Show();
});
return "";
}
}