我有一个名为FW Tools的免费命令行工具.效果很好.以下是我在控制台窗口中输入的示例行: -
ogr2ogr -f "ESRI Shapefile" -a_srs "EPSG:26986" -t_srs "EPSG:4326"
towns_geodetic.shp TOWNSSURVEY_POLY.shp
Run Code Online (Sandbox Code Playgroud)
我想改变最后的参数,基于我动态生成的一些列表(我使用Linq-to-Filesystem并获取所有文件名)然后调用该程序'n'次.
我不关心输出.
可以这样做吗?
这完全是在.NET环境下btw.
是否还有任何方法可以确保代码等待进程完成?
我会采取更详细的方法,并做这样的事情
string ApplicationName = "ogr2ogr";
string BaseOptions = "-f \"ESRI Shapefile\" -a_srs \"EPSG:26986\"
-t_srs \"EPSG:4326\"";
//Start your loop here
ProcessStartInfo oStartInfo = new ProcessStartInfo()
oStartInfo.FileName = ApplicationName;
oStartInfo.Arguments = BaseOptions + MyLoopLoadedItemsHere;
Process.Start(oStartInfo)
//If you want to wait for exit, uncomment next line
//oStartInfo.WaitForExit();
//end your loop here
Run Code Online (Sandbox Code Playgroud)
这样的东西更具可读性,至少在我看来是这样.
使用Process.Start.就像是 ...
Process.Start( "cmd /c Gregory -f \"ES RI Shape file\"
-a_Sirs \"PEGS:26986\" -t_Sirs \"PEGS:4326\"
towns_geodetic.Shep TOWNS SURVEY_PLOY.Shep" );
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2808 次 |
| 最近记录: |