版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u013779141/article/details/52421521
一、需求
最近遇到一个需求:利用Skyline(TB)Tools目录下的exe工具,生成tri文件,但是不能弹出exe窗体,而是后台默默执行。基于这个需求进行了一番探索。
Triangulate Irregular Elevation Grid.exe这个工具是讲XYZRGB文本文件转换为Tri文件的工具。
二、代码
public void ConvertXYZ2TRI(string pInputFile, string pOutputFile, float pResolution)
{
try
{
//参数依次为:NoWindow、InputFile、OutPutFile、Resolution
Process pProcess = new Process();
string pTriEXEPath = Application.StartupPath + "\\Triangulate Irregular Elevation Grid.exe";
//Tri文件路径不能包含空格,否则调用‘Triangulate Irregular Elevation Grid.exe’
//输入参数中带有的空格,程序会作为多个参数处理,导致程序运行异常
string pParams = "-NoWindow Y -InputFile " + '"' + pInputFile + '"' +" -OutputFile "+'"' + pOutputFile + '"'+" -Resolution " + pResolution;
ProcessStartInfo pProcessStartInfo = new ProcessStartInfo(pTriEXEPath, pParams);
pProcessStartInfo.WindowStyle = ProcessWindowStyle.Hidden;
pProcess.StartInfo = pProcessStartInfo;
pProcess.Start();
while (!pProcess.HasExited)
{
pProcess.WaitForExit();
}
pProcess.Close();
}
catch (Exception ex)
{
throw ex;
}
}
三、如何查看一个exe工具执行需要哪些参数
包装一个exe程序时候,如何获悉该exe需要哪些参数呢?可以在cmd命令行调用该exe程序,比如exe位于D盘下: