C#中如何将数据保存成文本格式?
C#中如何用代码实现将数据保存成TXT格式的文件比如将得到的数据保存成txt文件并保存在C盘?...
C#中如何用代码实现 将数据保存成TXT格式的文件比如将得到的数据 保存成txt文件 并保存在C盘?
展开
2个回答
推荐于2016-09-03
展开全部
主要是依靠IO下的几个类来实现,给你一段代码,仅供参考:------------------- string bFilePath =@"C:\a.txt";
FileStream fsMyfile = new FileStream(bFilePath,FileMode.Append, FileAccess.Write);
StreamWriter swMyfile = new StreamWriter(fsMyfile);
swMyfile.WriteLine("值");
swMyfile.Flush();
swMyfile.Close();
fsMyfile.Close();
FileStream fsMyfile = new FileStream(bFilePath,FileMode.Append, FileAccess.Write);
StreamWriter swMyfile = new StreamWriter(fsMyfile);
swMyfile.WriteLine("值");
swMyfile.Flush();
swMyfile.Close();
fsMyfile.Close();
2013-09-23
展开全部
完整的using System.IO;private void button1_Click(object sender, EventArgs e)
{string bFilePath =@"C:\a.txt";
FileStream fsMyfile = new FileStream(bFilePath,FileMode.Append, FileAccess.Write);
StreamWriter swMyfile = new StreamWriter(fsMyfile);
swMyfile.WriteLine("值");
swMyfile.Flush();
swMyfile.Close();
fsMyfile.Close();
}
{string bFilePath =@"C:\a.txt";
FileStream fsMyfile = new FileStream(bFilePath,FileMode.Append, FileAccess.Write);
StreamWriter swMyfile = new StreamWriter(fsMyfile);
swMyfile.WriteLine("值");
swMyfile.Flush();
swMyfile.Close();
fsMyfile.Close();
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询