I've recently asked several related questions to this issue but this time I want to get as straight to the point as possible with the concern I am having in my development.
We are trying to print tickets through a mobile printer and need to determine if the printer is online, offline or if there's an error so we can better handle it:
Here again is a snippet of my code when I print but can't seem to get it to trap if any issues occur:
Process process = new Process();
//process.StartInfo.CreateNoWindow = true;
process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
process.StartInfo.FileName = defFile;
if (rwPrinter.Length > 0)
{
process.StartInfo.Verb = "printto";
//process.StartInfo.Verb = (Path.Combine(System.Windows.Forms.Application.StartupPath, "printto.exe"));
process.StartInfo.Arguments = "\"" + rwPrinter + "\"";
}
else
{
process.StartInfo.Verb = "print";
}
try
{
process.Start();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
Pardon my hastiness on this as I have a boss that is impatient with me to get this working as desired, and please advise on how I can get this to error trap, thanks.