[代码片断]创建或写文件

 

[代码片断]创建或写文件
            string filename = "c:\\a.txt";
            
string content = "hello world!~";
            
byte[] data = Encoding.Unicode.GetBytes( content );
            
using( FileStream fs = new FileStream( filename, FileMode.Append ) ) {
                
//开始写入
                fs.Write( data, 0, data.Length );
                
//清空缓冲区、关闭流
                fs.Flush();
                fs.Close();
            }

posted @ 2009-07-17 09:08  kkun  阅读(267)  评论(0)    收藏  举报