我使用下面的字符串,在我的代码:如何将值分配给C#win应用程序的App.config中的键?
string AAR_FilePath = "\"C:\\MySQL\\MySQL Server 5.0\\bin\\mysqldump\"";
,我不希望在我的代码铁杆。所以,我需要使用,在我的app.config 我试着给相同的值,
<add key="Path_SqlDump" value="\"C:\\MySQL\\MySQL Server 5.0\\bin\\mysqldump\""></add>
但上面给我的错误,因为引号。
所有我需要的是,我应该能够分配“\” C:\ MySQL的\ MySQL服务器5.0 \ BIN \ mysqldump的\ “”
为字符串。怎么样 ?
public string AAR_FilePath = ConfigurationSettings.AppSettings["Path_SqlDump"].ToString();
public void CreateScript_AAR()
{
//AAR_FilePath = "\"C:\\MySQL\\MySQL Server 5.0\\bin\\mysqldump\"";
string commandLine = @"" + AAR_FilePath + " -u" + DbUid + " -p" + DbPwd + " " + DbName + " > " + Path_Backup + FileName_Backup;
System.Diagnostics.ProcessStartInfo PSI = new System.Diagnostics.ProcessStartInfo("cmd.exe");
PSI.RedirectStandardInput = true;
PSI.RedirectStandardOutput = true;
PSI.RedirectStandardError = true;
PSI.UseShellExecute = false;
System.Diagnostics.Process p = System.Diagnostics.Process.Start(PSI);
System.IO.StreamWriter SW = p.StandardInput;
System.IO.StreamReader SR = p.StandardOutput;
SW.WriteLine(commandLine);
SW.Close();
}
我已经试过,我没有得到我的结果。但是,如果我通过的值如.. string AAR_FilePath =“\”C:\\ MySQL \\ MySQL Server 5.0 \\ bin \\ mysqldump \“”; 它工作正常,如果你硬核! – Anuya 2010-05-11 03:09:48
我在这里展示的是正确的。如果它不起作用,那么您需要使用您用来访问此密钥的代码更新您的问题,并具体说明什么不起作用。 – John 2010-05-11 12:09:14