CommandShell.cs
(完整代码) 1KBusing System.Diagnostics;
using System.Text;
namespace 语文字帖
{
public class CommandShell
{
private Process proc = null;
public CommandShell()
{
}
public string Echo => txt.ToString();
private readonly StringBuilder txt = new StringBuilder();
public void RunCmd(string cmd, bool isEchoNow = true)
{
proc = new Process();
proc.StartInfo.CreateNoWindow = true;
proc.StartInfo.FileName = "cmd.exe";
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.RedirectStandardError = true;
proc.StartInfo.RedirectStandardInput = true;
proc.StartInfo.RedirectStandardOutput = true;
proc.Start();
proc.StandardInput.WriteLine(cmd);
proc.StandardInput.WriteLine("exit");
while (!proc.StandardOutput.EndOfStream)
{
string s = proc.StandardOutput.ReadLine();
txt.AppendLine(s);
}
proc.Close();
}
}
}
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
