把textbox中的内容写入指定的文件(C#)

把textbox中的内容写入指定的文件(C#)
           String curRowText = "Hello!"
           FileStream fs = new FileStream("D:\\file.txt",FileMode.Append,FileAccess.Write);
            StreamWriter sw = new StreamWriter(fs);
            sw.Flush();
            sw.Write(curRowText);
            sw.Flush();
            sw.Close();


或者:
StreamWriter writer = null;
try
{
writer = new StreamWriter(strFileName, true);
writer.WriteLine(strCmdText);
}
catch (Exception ex)
{
//进行异常处理
}
finally
{
if (writer != null) writetofile.Close();
}
return false;

你可能感兴趣的:(把textbox中的内容写入指定的文件(C#))