用c#如何编写记事本代码?
1个回答
展开全部
public void writeInfo()
{
TxtPath = "C:\\";
FileName = "TXTFileName.txt";
string stream = TxtPath + FileName;
FileStream aFile = new FileStream(stream,FileMode.OpenOrCreate, FileAccess.Write);
StreamWriter sw = new StreamWriter(aFile);
sw.Flush();
sw.BaseStream.Seek(0, SeekOrigin.Begin);
sw.WriteLine(wanttowritedata);
sw.Flush();
sw.Close();
}
执行就可以直接保存在C盘下面了。
sw.WriteLine(wanttowritedata);
这裏面写你想写的资料,你可以先定义成字符串,然后赋值给wanttowritedata
{
TxtPath = "C:\\";
FileName = "TXTFileName.txt";
string stream = TxtPath + FileName;
FileStream aFile = new FileStream(stream,FileMode.OpenOrCreate, FileAccess.Write);
StreamWriter sw = new StreamWriter(aFile);
sw.Flush();
sw.BaseStream.Seek(0, SeekOrigin.Begin);
sw.WriteLine(wanttowritedata);
sw.Flush();
sw.Close();
}
执行就可以直接保存在C盘下面了。
sw.WriteLine(wanttowritedata);
这裏面写你想写的资料,你可以先定义成字符串,然后赋值给wanttowritedata
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询