日期:2014-05-17 浏览次数:20485 次
FileStream myFs = new FileStream(txtFilePath, FileMode.Create);//txtFilePath为生成txt文件的路径
StreamWriter mySw = new StreamWriter(myFs);
mySw.WriteLine(writeStr);//writeStr为要写入的字符串
mySw.Close();
myFs.Close();
/// <summary>
/// WirteFile
/// </summary>
/// <param name="str"></param>
private void WirteFile(string str)
{
if (!File.Exists(@"文件路径"))
{
try
{
//创建文件
FileStream fs = new FileStream(@"文件路径", FileMode.Create, FileAccess.ReadWrite);
StreamWriter sw = new StreamWriter(fs);
//写入数据
sw.WriteLine(str);
sw.Close();
fs.Close();
//
}
catch()
{
}
}
else
{
&