0
이 코드를 실행하려고 할 때 런타임 예외가 발생하는 이유는 무엇입니까?WaitForExit() 런타임 예외. (cmd 프로세스가 끝날 때까지 기다리는 중)
Sub BtnNowClick(sender As Object, e As EventArgs)
Dim myProcess As New Process
Dim processFile As String = dlgFolder.SelectedPath
Dim pyLocationDel As String = Path.Combine(dlgFolder.SelectedPath, "pdfmerge.py")
Directory.SetCurrentDirectory(dlgFolder.SelectedPath)
myProcess.Start(pyLocationDel)
myProcess.WaitForExit()
System.IO.File.Delete(pyLocationDel)
End Sub
기본적으로 원하는 것은 프로세스가 완료된 것을 감지하고 프로세스가 완료되면 특정 파일을 삭제하는 것입니다.
System.NullReferenceException: Object reference not set to an instance of an object.
at lgaPDF.MainForm.BtnNowClick(Object sender, EventArgs e) in C:\Documents and Settings\student3\My Documents\SharpDevelop Projects\lgaPDF\lgaPDF\MainForm.vb:line 184
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
at lgaPDF.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
덕분에, 그러나, 나는 그것을 시도하지만 난 받고 있어요 새 오류'System.InvalidOperationException :이 개체와 연결된 프로세스가 없습니다. ' – Brian
질문의 코드를 업데이트했습니다. – Brian
그와 같은 누군가의 대답을 파기 할 수는 없습니다. 새로운 질문을 시작하십시오. –