【发布时间】:2010-07-13 14:28:06
【问题描述】:
我想使用 cmd shell 提取 .rar 文件,所以我写了这段代码:
string commandLine = @"c:\progra~1\winrar\winrar e c:\download\TestedU.rar c:\download";
ProcessStartInfo PSI = new ProcessStartInfo("cmd.exe");
PSI.RedirectStandardInput = true;
PSI.RedirectStandardOutput = true;
PSI.RedirectStandardError = true;
PSI.UseShellExecute = false;
Process p = Process.Start(PSI);
StreamWriter SW = p.StandardInput;
StreamReader SR = p.StandardOutput;
SW.WriteLine(commandLine);
SW.Close();
第一次正常,第二次什么都不显示。
【问题讨论】:
-
powershell 或 cmd 脚本会不会更合适?您有什么特殊原因要在代码中执行此操作吗?
-
上面引用的 Chilkat 库是一种享受。唯一令人恼火的是它的非托管代码。
标签: c# .net compression