2011-08-20 167 views
1

我目前正在构建一个WPF应用程序。我希望能够选择二进制文件,使用命令行命令行参数将其解码为.csv文件,在我的应用程序中编辑其值,然后使用解码工具将其解码为二进制文件。 'm卡在正在输入我的命令行参数到命令提示符中。我搜索了一些东西,但我只能找到关于如何从代码打开命令提示符的信息,而不是如何执行命令。在命令提示符下使用c#为wpf应用程序执行命令

任何帮助将不胜感激。 谢谢!

+1

有很多受骗者对SO为:如何在C#中的shell中执行命令? WPF与这个问题没有任何关系。 –

回答

4

结帐处理类,它是.NET框架的一部分 - 有关更多信息和示例代码,请参阅its documentation at MSDN

编辑 - 按评论:

即开始7zip的,读的StdOut

using System; 
using System.Diagnostics; 
using System.IO; 

class Program 
{ 
    static void Main() 
    { 
    ProcessStartInfo start = new ProcessStartInfo(); 
    start.FileName = @"C:\7za.exe"; // Specify exe name. 
    start.UseShellExecute = false; 
    start.RedirectStandardOutput = true; 

    using (Process process = Process.Start(start)) 
    { 
     // Read in all the text from the process with the StreamReader. 
     using (StreamReader reader = process.StandardOutput) 
     { 
     string result = reader.ReadToEnd(); 
     Console.Write(result); 
     } 
    } 
    } 
} 

一些链接样本

示例代码:

+0

添加一个代码示例更多upvotes :) –

+1

按要求添加了一个示例和一些链接到几个样本... – Yahia

相关问题