作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用名为 UltraCompare 的第三方比较工具来比较两个文件夹。下一行调用该程序并打开两个文件...但这除了打开它们之外什么都不做,而且对于文件夹它不能正常工作。
Process.Start("C:\\Program Files\\IDM Computer Solutions\\UltraCompare\\uc.exe",
textBoxContents1 + " " + textBoxContents2);
我想使用以下命令行调用打开两个文件夹,对它们进行比较,并将结果存储在 output.txt 中:uc -d -dmf "c:\dir1""c :\dir2"-o "c:\output.txt"
此外,我需要为文件夹使用变量,而不是对路径进行硬编码。
我如何将它应用到我的 C# 代码中?
更新 1:
我已经根据您的建议修改了我的代码:
var p = new System.Diagnostics.Process();
p.StartInfo.FileName = "C:\\Program Files\\IDM Computer Solutions\\UltraCompare\\uc.exe";
p.StartInfo.Arguments = String.Format("-d -dmf \"{0}\" \"{1}\" -o c:\\output2.txt",
textBoxContents1, textBoxContents2);
p.Start();
我想知道为什么包含参数的第三行仍然不起作用...
更新 2:
我的错误。它现在正在工作!只是不显示 UltraCompare 中的文件夹,但它仍在写入和保存输出。谢谢大家!
最佳答案
你可以使用
yourProcess.StartInfo.Arguments = " .....";
示例
var p = new System.Diagnostics.Process();
p.StartInfo.FileName = "C:\\Program Files\\IDM Computer Solutions\\UltraCompare\\uc.exe";
p.StartInfo.Arguments = String.Format("-d -dmf {0} {1} -o c:\output.txt",textBoxContents1, textBoxContents2);
p.Start();
关于c# - 如何在 C# 中执行带有参数的命令行参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14587562/
我是一名优秀的程序员,十分优秀!