C# 中怎么将一维数组保存为txt文本并保存!
1个回答
展开全部
//保存到本地的路径
string mFileFullname = @"C:\999\一维文本.txt";
//编写器
System.IO.StreamWriter mStreamWriter = new System.IO.StreamWriter(mFileFullname, false, System.Text.Encoding.UTF8);
string[] mStrs1 = { "1", "2", "3", "4" };
for (int i = 0; i < mStrs1.Length; i++)
{
mStreamWriter.WriteLine(mStrs1[i]);
}
//用完StreamWriter的对象后一定要及时销毁
mStreamWriter.Close();
mStreamWriter.Dispose();
mStreamWriter = null;
string mFileFullname = @"C:\999\一维文本.txt";
//编写器
System.IO.StreamWriter mStreamWriter = new System.IO.StreamWriter(mFileFullname, false, System.Text.Encoding.UTF8);
string[] mStrs1 = { "1", "2", "3", "4" };
for (int i = 0; i < mStrs1.Length; i++)
{
mStreamWriter.WriteLine(mStrs1[i]);
}
//用完StreamWriter的对象后一定要及时销毁
mStreamWriter.Close();
mStreamWriter.Dispose();
mStreamWriter = null;
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |