Hey all,
I've create a console app that handles some pdf conversions for me. In this app I send some text to the console and if an error occurs, I send text to Console.Error...
VB.net Code:
'for console writes... Console.WriteLine("Converting page " & pageNumber.ToString) 'for error writes... Console.Error.WriteLine("An error occur during the pdf page conversion.")
I am then running the console app from a windForm app with this code...
My intent is have the standard output go to the console, but redirect the error so I can display and log it, However when I set RedirectStandardError=True, it is redirecting all output including the standard output which I want to remain in the console window.VB.Net Code:
Private Function pdfToImg(pdfPath As String, destinationPath As String, pdfToImgAppPath As String) As String Dim returnErrString As String = "" Dim p As New Process With p.StartInfo .FileName = pdfToImgAppPath .Arguments = String.Format("{0} {1}", pdfPath, destinationPath) .RedirectStandardOutput = False .RedirectStandardError = True .UseShellExecute = False End With p.Start() p.WaitForExit(30000) If Not p.HasExited Then p.Kill() returnErrString = "An unknow error has occured in the pdf conversion. The process never ended." Else returnErrString = p.StandardError.ReadToEnd End If Return returnErrString End Function
Has anyone seen this behavior before and know how to resolve it?
thanks
kevin




Reply With Quote