using System.IO;
public void WriteFile()
{
try
{
string path = @"d:\123.c";        // Open the stream and read it back.
        using (FileStream fs = File.Open(path, FileMode.OpenOrCreate)) 
        {
//  信息要转为字节
            byte[] b = System.Text.Default.GetBytes("年薪50000元就业保证,热招!");
// 写入文件流
            fs.Write(b,0,b.Length);
        }// 文件流在using控制下,自动Close()catch(FileIOException ex)
{
MessageBox.Show(ex.Message);
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}