本文介绍了Shell out .exe(Serialize?)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我想从C#运行外部程序。我有该程序的源代码。基本上它需要读取参数文本或XML文件并运行应用程序。

任何建议都将不胜感激。



例如:



但是我不知道如何读取.exe的参数文件?



Hello,
I would like to run an external program from C#. I have the source code for the program. Basically it would need to read a parameters text or XML file and run the application.
Any suggestions would be appreciated.

For example:

However I don''t know how to read in a parameters file for the .exe?

class Program
{
    static void Main()
    {
    LaunchCommandLineApp();
    }

    /// <summary>
    /// Launch the legacy application with some options set.
    /// </summary>
    static void LaunchCommandLineApp()
    {
    // For the example
    const string ex1 = "C:\\";
    const string ex2 = "C:\\Dir";

    // Use ProcessStartInfo class
    ProcessStartInfo startInfo = new ProcessStartInfo();
    startInfo.CreateNoWindow = false;
    startInfo.UseShellExecute = false;
    startInfo.FileName = "dcm2jpg.exe";
    startInfo.WindowStyle = ProcessWindowStyle.Hidden;
    startInfo.Arguments = "-f j -o \"" + ex1 + "\" -z 1.0 -s y " + ex2;

    try
    {
        // Start the process with the info we specified.
        // Call WaitForExit and then the using statement will close.
        using (Process exeProcess = Process.Start(startInfo))
        {
        exeProcess.WaitForExit();
        }
    }
    catch
    {
        // Log error.
    }
    }
}

推荐答案


这篇关于Shell out .exe(Serialize?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 04:36