程序中已经得到一个string(也可以是byte[],需要进行编码),希望将它存入d:\1.txt 中
using system.io;
string path = @"d:\1.txt";//这是地址
string text = "这里是要写入的内容";
filestream fs = new filestream(path, filemode.create);
streamwriter sw = new streamwriter(fs, encoding.unicode);
sw.write(text);
sw.close();
fs.close();