C# Verbatim 似乎不适用于 .startinfo.arguments?
我有一个应用程序,我可以使用它从目录中的多个 MSI(相同的 MSI,不同版本)中进行选择,并且我将能够从该应用程序安装或卸载。
我拉入 MSI 列表,包含完整路径,
string MSILocation = @"C:\test\";
string[] MSIFiles = Directory.GetFiles(MSILocation, "*.MSI", SearchOption.TopDirectoryOnly);
从这里我填充一个列表视图,一旦选择一个,我就点击安装按钮。 但是当我检查安装代码时,逐字记录似乎搞砸了。
string MSIname = lboMSIList.SelectedItem.ToString();
Process p = new Process();
p.StartInfo.FileName = "MSIEXEC.EXE";
p.StartInfo.Arguments = @"/i " + MSIname;
p.Start();
即使列表视图显示带有 single / 的文件,最终结果总是以 double / 出现,
其中的某个地方丢失了文字字符串。
如果我更改代码并运行 .FileName = @"msiexec.exe /i C:\test\test1.msi" 它工作得很好,但我需要能够从列表中进行选择文件名。
有什么想法吗?
I have an app with which i can select from multiple MSI's (same msi, different versions) in a directory, and i will be able to install or uninstall from this app.
I pull in the list of MSI's, complete with full path, with
string MSILocation = @"C:\test\";
string[] MSIFiles = Directory.GetFiles(MSILocation, "*.MSI", SearchOption.TopDirectoryOnly);
From here i populate a listview, and once one is selected i hit the install button.
But when i go through my installing code, the verbatim seems to screw up.
string MSIname = lboMSIList.SelectedItem.ToString();
Process p = new Process();
p.StartInfo.FileName = "MSIEXEC.EXE";
p.StartInfo.Arguments = @"/i " + MSIname;
p.Start();
Even though the listview shows the file with single / the end result always comes out with double /
Somewhere in there its losing the literal string.
If i change the code up and run .FileName = @"msiexec.exe /i C:\test\test1.msi" it works just fine, but i need to be able to select from a list of filenames.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用上面的
MSIFiles
文件名数组填充列表视图使用 Path.combine 如下
use above
MSIFiles
array of file names to populate the listviewUse Path.combine as below