I'm very new to c# and for a project I've downloaded some code Authored by tixiv from https://www.das-labor.org/trac/browser/microcontroller/src-atmel/laserExposer/PC_Frontend?order=name
I'm trying to open a pdf file within a form.
The error I'm getting is:
An exception of type 'System.ComponentModel.Win32Exception' occurred in System.dll but was not handled in user code Additional information: The system cannot find the file specified If there is a handler for this exception, the program may be safely continued.
Question 1.
I am confused by the line:
p.StartInfo.FileName = "E:/Test/test2.pdf";
can I use an empty string or do I need to define a specific file and location as above?
Question 2. What do the switches (-f 1 -l 1 -r 600)
in the following statement mean?
p.StartInfo.Arguments = "-mono -f 1 -l 1 -r 600 " + openPdfDialog.FileName + " E:/Documents/Eagle Projects/Testing/";
Question 3. What is the correct way to catch this exception?
private void openFileDialog1_FileOk(object sender, CancelEventArgs e)
{
Process p = new Process();
// Redirect the output stream of the child process.
// StartInfo Gets or sets the properties to pass to the Start method of the Process.
p.StartInfo.UseShellExecute = false; // UseShellExecute Setting this property to false enables you to redirect input, output, and error streams.
p.StartInfo.RedirectStandardOutput = true; // true if output should be written to Process.StandardOutput;
p.StartInfo.FileName = "E:/Test/test2.pdf"; // The default is an empty string.
p.StartInfo.Arguments = "-mono -f 1 -l 1 -r 600 " + openPdfDialog.FileName + " E:/Documents/Eagle Projects/Testing/";
p.Start();
// Do not wait for the child process to exit before
// reading to the end of its redirected stream.
// Read the output stream first and then wait.
string output = p.StandardOutput.ReadToEnd();
p.WaitForExit();
FileInfo f = new FileInfo("c:\\Windows\\Temp\\-000001.pbm");
StreamReader s = f.OpenText();
...