C# 讀取存儲(chǔ)在本地txt中的參數(shù)
讀?。篎ormLoad
/**
*
* 初始化算法參數(shù)配置
*
* **/
try
{
this.ParamPath = File.ReadAllText(@"./TempData/ParamPath.txt");
textBox3.Text = this.ParamPath;
}
catch
{
}
寫入
FolderBrowserDialog folder = new FolderBrowserDialog();
folder.Description = "選擇參數(shù)文件存放目錄";
if (folder.ShowDialog() == DialogResult.OK)
{
//MessageBox.Show(folder.SelectedPath);
textBox3.Text = folder.SelectedPath;
ParamPath = folder.SelectedPath;
}
try
{
//如果文件不存在,則創(chuàng)建;存在則覆蓋
System.IO.File.WriteAllText(@"./TempData/ParamPath.txt", ParamPath, Encoding.UTF8);
}
catch (Exception exp)
{
MessageBox.Show("參數(shù)配置路徑寫入本地失敗-失敗原因:" + exp.Message);
}
本文摘自 :https://blog.51cto.com/u