嘿,我正在尝试使用 PowerISO 的命令行程序 piso。
我正在使用 C# 打开一个进程并输入命令以挂载 cd/dvd。这工作正常,每次都会安装 cd/dvd。
问题是 .ReadToEnd() 不会停止阅读,程序在这里挂起。似乎命令提示符的响应应该是
PowerISO Version 4.5 Copyright(C) 2004-2009 PowerISO Computing, Inc Type piso -? for help
Mount successfully
但是我只能:
PowerISO Version 4.5 Copyright(C) 2004-2009 PowerISO Computing, Inc Type piso -? for help
并且程序将永远继续读取,永远不会成功输出 Mount。
这是我的 C# 代码:
String output = "";
System.Diagnostics.Process cmd = new System.Diagnostics.Process();
cmd.StartInfo.WorkingDirectory = @"C:\"; //@"
cmd.StartInfo.FileName = Path.Combine(Environment.SystemDirectory, "cmd.exe");
cmd.StartInfo.UseShellExecute = false;
cmd.StartInfo.RedirectStandardInput = true;
cmd.StartInfo.RedirectStandardOutput = true;
cmd.StartInfo.RedirectStandardError = false;
cmd.Start();
cmd.StandardInput.WriteLine(MountPrgLoc + " " +
MountPrgCmd_Mount + " " +
location + " " +
drive);
StreamReader sr = cmd.StandardOutput;
output = sr.ReadToEnd() ;
MessageBox.Show(output);
在此先感谢您的帮助-斯科特
------------------编辑-----------------更多信息:
/* DVD Attributes */
String name = "My Movie Title";
String location = "\"" + @"C:\Users\Razor\Videos\iso\Movie.iso" + "\"";
String drive= "H:";
String format = ".iso";
/* Special Attributes */
String PlayPrg = "Windows Media Center";
String PlayPrgLoc = @"%windir%\ehome\"; //@"
String MountPrg = "PowerISO";
String MountPrgLoc = "\"" + @"C:\Program Files (x86)\PowerISO\piso.exe" + "\""; //@"
String MountPrgCmd_Mount = "mount";
String MountPrgCmd_Unmount = "unmount";