执行以excel文件为输入的exe文件的C#代码

执行以excel文件为输入的exe文件的C#代码,c#,excel,exe,directory,C#,Excel,Exe,Directory,我有一个exe文件,将excel文件的路径作为输入。 它生成多个拆分的excel文件作为输出。 但是需要指定输出目录,将spliited输出文件存储在其中。 有人能帮我吗。您可以使用该类来实现这一点: using (p = new System.Diagnostics.Process()) { p.StartInfo.FileName = "PathTo.exe"; // Provide command line argument p.StartInfo.Argument

我有一个exe文件,将excel文件的路径作为输入。 它生成多个拆分的excel文件作为输出。 但是需要指定输出目录,将spliited输出文件存储在其中。 有人能帮我吗。

您可以使用该类来实现这一点:

using (p = new System.Diagnostics.Process())
{
    p.StartInfo.FileName = "PathTo.exe";
    // Provide command line argument
    p.StartInfo.Arguments = "arg1 arg2 arg3 \"Arg with whitespace\"";
    // You can also try to set the working directory when you run the process
    p.UseShellExecute = false;
    p.WorkingDirectory = @"C:\OutputDirectory";
    p.Start();
    // In case you want to wait for the process to exit
    p.WaitForExit();
}

嗨,谢谢你的回答。Bt在通过参数后,我已经得到了一个exe文件窗口。我只是不知道如何将exe的输出重定向到新目录。@AnanyaMalik:这取决于您调用的exe文件。也许您可以在参数中更改它,也许您可以通过设置工作目录来解决它。我已经更新了样本。Thnx很多。我让它工作了……)