Monodroid – Write A File

by Jason Carter on April 27, 2011 · 1 comment

In Mono for Android you can write files very simply.

// Compose a string that consists of three lines.
string lines = "First line.\r\nSecond line.\r\nThird line.";

// Write the string to a file.
StreamWriter file = new System.IO.StreamWriter(“/”);
file.WriteLine(lines);

file.Close();

{ 1 comment… read it below or add one }

IVAN June 27, 2011 at 3:47 am

But, how can I define the file name?
StreamWriter file = new System.IO.StreamWriter(“/file.txt”); //doesn’t seem to work…
tnhx in advance…

Leave a Comment