我正在将我的 c# 申请表与文本文件连接起来。但我不希望它被硬编码。到目前为止,我在文件中的代码如下所示。我不想显示文件名和路径文件。我宁愿将它放入 app.config 文件并从 app.config 文件中使用它。你能告诉我我必须在这个文件和 app.config 文件中做哪些更改:
private void button1_Click(object sender, EventArgs e)
{
string sqlConnectionString = @"C:\Jaspreet_Files\LoadOrgInPortal.txt";
var fileContents = System.IO.File.ReadAllText(@"C:\Jaspreet_Files\LoadOrgInPortal.txt");
fileContents = fileContents.Replace("{param_1}", textBox1.Text.ToString());
fileContents = fileContents.Replace("{param_2}", textBox2.Text.ToString());
fileContents = fileContents.Replace("{param_3}", textBox3.Text.ToString());
fileContents = fileContents.Replace("{param_4}", textBox4.Text.ToString());
System.IO.File.WriteAllText(@"C:\Jaspreet_Files\NewLoadOrgInPortal.txt", fileContents);
Application.Exit();
}
我的 app.config 文件目前是空的。我的意思是我还没有在那里做任何编码。