How to run an application and send file names?

  • Thread starter Thread starter NiceStepUp
  • Start date Start date
N

NiceStepUp

Guest
I've donwloaded the following maps:

andorra-latest.osm.pbf https://download.geofabrik.de/europe/andorra-latest.osm.pbf
azores-latest.osm.pbf https://download.geofabrik.de/europe/azores-latest.osm.pbf
cyprus-latest.osm.pbf https://download.geofabrik.de/europe/cyprus-latest.osm.pbf

I need to merge the above maps. So I am using osmconvert to merge maps. I read this answer about merging maps. So if I copy the following command and paste into command window, then it works fine - it creates all.osm.pbf file:

1510336.png

So desired file all.osm.pbf is created:

1510335.png

However, now I would like to call this command programmatically. I mean, I would like to call the above command through C#. So I've tried this code in my Console application:

static Process process = new Process();

static void Main(string[] args)
{
process.EnableRaisingEvents = true;
process.OutputDataReceived += new System.Diagnostics.DataReceivedEventHandler(process_OutputDataReceived);
process.ErrorDataReceived += new System.Diagnostics.DataReceivedEventHandler(process_ErrorDataReceived);
process.Exited += new System.EventHandler(process_Exited);

process.StartInfo.FileName = @"osmconvert.exe";
process.StartInfo.Arguments = @"osmconvert.exe andorra-latest.osm.pbf --out-o5m | osmconvert.exe - azores-latest.osm.pbf | osmconvert.exe - cyprus-latest.osm.pbf -o=all.osm.pbf";
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.RedirectStandardOutput = true;

process.Start();
process.BeginErrorReadLine();
process.BeginOutputReadLine();
}

But I always see the following error:

1510337.png

My files are located in D:\Downloads:

1510338.png

I've tried this code, however, the error is the same:

process.StartInfo.FileName = @"D:\Downloads\osmconvert.exe";
process.StartInfo.Arguments = @"D:\Downloads\osmconvert.exe D:\Downloads\andorra-latest.osm.pbf --out-o5m | D:\Downloads\osmconvert.exe - D:\Downloads\azores-latest.osm.pbf | D:\Downloads\osmconvert.exe - D:\Downloads\cyprus-latest.osm.pbf -o=D:\Downloads\all.osm.pbf";

and:

process.StartInfo.FileName = @"D:\\Downloads\\osmconvert.exe";
process.StartInfo.Arguments = @"D:\\Downloads\\osmconvert.exe D:\\Downloads\\andorra-latest.osm.pbf --out-o5m | D:\\Downloads\\osmconvert.exe - D:\\Downloads\\azores-latest.osm.pbf | D:\\Downloads\\osmconvert.exe - D:\\Downloads\\cyprus-latest.osm.pbf -o=D:\\Downloads\\all.osm.pbf";
Could you say, please, what am I doing wrong?

Continue reading...
 
Back
Top