如何从C#运行.exe [英] How to run .exe from C#

查看:101
本文介绍了如何从C#运行.exe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用C#开发wpf应用程序.我在应用程序中使用grib文件.我想将此grib文件内容转换为csv文件.从命令提示符下,我可以轻松地做到这一点.对于此命令提示符,我需要转到degrib.exe的文件夹位置,即c:\ ndfd \ degrib \ bin.对于任何其他路径,命令将不会执行.我正在使用以下命令

I am developing wpf application in C#. I am using grib files in my application. I want to convert this grib file content into csv file. From command prompt I can easily do this. For this in command prompt I need to go to the folder location of degrib.exe i.e. c:\ndfd\degrib\bin. For any other path command will not get executed. I am using the following commands

C:\ndfd\degrib\bin\degrib D:\Documents\Pacificwind.grb -C -msg 1 -Csv
C:\ndfd\degrib\bin\degrib D:\Documents\Pacificwind.grb -C -msg all -nMet -Csv

命令成功执行.我可以在C:\ ndfd \ degrib \ bin文件夹中看到生成的csv文件.我应该如何从C#执行相同的命令.我看到了不同的示例,但没有一个对我有用.您能否提供任何可解决上述问题的代码或链接?

The commands get successfully executed. I am able to see generated csv files at C:\ndfd\degrib\bin folder. How should I execute the same command from C#. I have seen different examples but none of them worked for me. Can you please provide me any code or link through which I can resolve the above issue ?

推荐答案

这将起作用,除非您提供的路径不正确:

This will work, unless the paths you provided are incorrect:

Process.Start(@"C:\ndfd\degrib\bin\degrib", 
              @"D:\Documents\Pacificwind.grb -C -msg 1 -Csv");

Process.Start(@"C:\ndfd\degrib\bin\degrib", 
              @"D:\Documents\Pacificwind.grb -C -msg all -nMet -Csv")

这篇关于如何从C#运行.exe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆