我要在安装文件中改写config中的数据联接字,为什么会找不到文件,我如何改?
public override void Install(System.Collections.IDictionary stateSaver)
{ base.Install (stateSaver);
try
{
CreateTxt(this.Context.Parameters["targetdir"]);
System.Diagnostics.Process sqlProcess = new Process();
sqlProcess.StartInfo.FileName = "osql.exe";
sqlProcess.StartInfo.Arguments = string.Format(" -U {0} -P {1} -S {2} -i {3}db.sql", this.Context.Parameters["user"], this.Context.Parameters["pwd"], this.Context.Parameters["dbname"], this.Context.Parameters["targetdir"]);
sqlProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
sqlProcess.Start();
sqlProcess.WaitForExit();  
sqlProcess.Close();
}
catch(Exception ce)
{
MessageBox.Show(ce.Message.ToString());
}

try
{
FileInfo fileInfo=new FileInfo(Application.StartupPath+"\\Rnas.exe.config");
if(!fileInfo.Exists)
{
throw new Exception("未能找到相关文件");
} XmlDocument xmlDocument=new XmlDocument();
xmlDocument.Load(fileInfo.FullName);

XmlNodeList nodes=xmlDocument.GetElementsByTagName("add");
for(int i=0;i<nodes.Count;i++)
{
XmlAttribute att=nodes[i].Attributes["key"];
if (att.Value=="strConn") 
{
att=nodes[i].Attributes["value"];
att.Value=string.Format("Server=(local);database={0};User ID={1};Password={2};", this.Context.Parameters["dbname"], this.Context.Parameters["user"], this.Context.Parameters["pwd"]);
break;
}
}
xmlDocument.Save(fileInfo.FullName);
}
catch(Exception ce)
{
throw ce;
} }