2014年4月25日 星期五

[C#] Create/Open File and Clear all the text

Stream myStream;
myStream = File.Open(SetupFilePath, FileMode.OpenOrCreate); //Open or Create
myStream.Close();

myStream = File.Open(SetupFilePath, FileMode.Truncate); //Reopen and clear all the text

StreamWriter
sw = new StreamWriter(myStream, System.Text.Encoding.Unicode);

sw.WriteLine("test");

沒有留言:

張貼留言