【问题标题】:StandardOutput Process标准输出过程
【发布时间】:2013-09-26 17:29:45
【问题描述】:

对于我的程序,我需要反编译一个 swf ...我为此使用 flasm!

对于我的第一次尝试,我将结果导出到 txt 文件并阅读此 txt

string newPath = Path.GetTempPath() + @"DasLol.txt";

        if(File.Exists(newPath))
        {
            File.Delete(newPath);
        }

        string dasCmd = "/c flasm.exe -d \"" + path + "\" > " + newPath;

        ProcessStartInfo procStartInfo = new ProcessStartInfo(@"C:\Windows\System32\cmd.exe", dasCmd);

        Process flasm = new Process {StartInfo = procStartInfo};

        flasm.Start();
        flasm.WaitForExit();
string dasString = File.ReadAllText(newPath);

但是如何重定向 de StandardOutput 以在控制台中直接读取我的“dasString”? (并且不要使用临时 txt)

【问题讨论】:

标签: c# .net process redirectstandardoutput


【解决方案1】:

允许标准输出被重定向,等待进程退出,读取。

procStartInfo.UseShellExecute = false;
procStartInfo.RedirectStandartOutput = true;
...
flasm.WaitForExit();
string output = flasm.StandartOutput.ReadToEnd();

【讨论】:

  • 没用!!如果 procStartInfo.RedirectStandardOutput = true;控制台出现,但未执行命令(“dasCmd”)。 ( PS new dasCmd ; string dasCmd = "/c flasm.exe -d \"" + path + "\" ";)
  • 没有执行是什么意思?
猜你喜欢
  • 1970-01-01
  • 2013-09-18
  • 1970-01-01
  • 2021-10-20
  • 2011-08-29
  • 1970-01-01
  • 2011-07-11
  • 1970-01-01
  • 2012-09-25
相关资源
最近更新 更多