C sharp应用下的txt文件写入

方法如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
//file storage function
public bool txt_file_generate(Dictionary<int, string> dic_val)
{
FolderBrowserDialog my_diaglog = new FolderBrowserDialog();
string save_path = string.Empty;
bool save_ok;
string val = null;
string file_name = DateTime.Now.ToString("yyyyMMddHHmmss") + "_Accurtestlogs.txt";
if (my_diaglog.ShowDialog() == DialogResult.OK)
{
save_path = my_diaglog.SelectedPath + "\\" + file_name;
}
FileStream fs = new FileStream(save_path, FileMode.Append);
StreamWriter sw = null;
sw = new StreamWriter(fs);
foreach (KeyValuePair<int, string> pair in dic_val)
{
sw.WriteLine(pair.Value);
}
sw.Close();
fs.Close();
save_ok = true;
return save_ok;
}

C sharp应用下的txt文件写入
http://example.com/2024/07/21/C sharp应用下的txt文件写入/
作者
xiao cuncun
发布于
2024年7月21日
许可协议