关于这一点,我已经搜索了很多,但没有任何关于这种具体情况的例子。
我想压缩写在文本框(dirdes)上的目录,并在富文本框上显示输出(
_output
).
它不是压缩写在文本框上的目录,而是压缩bin目录。
private void button3_Click(object sender, EventArgs e)
{
string dirdes1 = dirdes.Text;
string strCmdText;
strCmdText = "/C compact /c /s /a /i /exe:lzx '" + dirdes1 + " *'";
Process lzx = new Process();
System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
lzx.StartInfo.FileName = "cmd.exe";
lzx.StartInfo.UseShellExecute = false;
lzx.StartInfo.Arguments = strCmdText;
lzx.StartInfo.RedirectStandardOutput = true;
lzx.Start();
_output.Text = lzx.StandardOutput.ReadToEnd();
}
编辑:我认为这是一个报价错误。因为目录必须是这样的
"C:\"
不是这样的
'C:\'