How can I catch all exceptions in C# from libtiff.net TIFFCP.exe I would like to get exceptions from TTIFFCP.exe(Merge, Split) such as DirectoryNotFoundException, FileNotFoundException ... I can see these errors on visula studio debugger window but it does not pass catch block.
I tried like these(I made an error deliberately)
<pre><code>
<hr/>
Code A :
string[] arguments =
{
@"Sample Data\EEEEEEE.tif",
@"Sample Data\marbles.tif",
"MergeTiffImages.tif"
};
TiffCP.Program.Main(arguments);
===> nothing return
<hr/>
Code B :
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.FileName = @"TiffCP.exe";
string path1 = @"Sample Data\EEEEEEE.tif";
string path2 = @"Sample Data\marbles.tif";
string path3 = "MergeTiffImages.tif";
p.StartInfo.Arguments = "\"" + path1 + "\"" + ", \"" + path2 + "\"" + ", \"" + path3 + "\"";
p.Start();
string t = p.StandardOutput.ReadToEnd();
===> string t => ""
<hr/>
Code C :
Process myProcess = new Process();
ProcessStartInfo myProcessStartInfo = new ProcessStartInfo(@"TiffCP.exe");
string path1 = @"Sample Data\EEEEEEE.tif";
string path2 = @"Sample Data\marbles.tif";
string path3 = "MergeTiffImages.tif";
myProcessStartInfo.StartInfo.Arguments = "\"" + path1 + "\"" + ", \"" + path2 + "\"" + ", \"" + path3 + "\"";
myProcessStartInfo.UseShellExecute = false;
myProcessStartInfo.RedirectStandardError = true;
myProcess.StartInfo = myProcessStartInfo;
myProcess.Start();
StreamReader myStreamReader = myProcess.StandardError;
string t = myStreamReader.ReadLine();
myProcess.Close();
===> string t => Open: Failed to open "Sample Data\EEEEEEE.tif"
</code></pre>
but it does not pass catch block
Is it possible to get Errors from TIFFCP.exe? thanks in advance.