I have a project that uses Process to marge some files, now because the merging can take quite sometime I've used BackgroundWork. The main problem I'm facing is to know when the Process is done because I want to delete the files that it was merging with so that the file will only contain the finished output which is a file that is produced by merging these other files.
I have this code.
Private proc1 As New Process proc1.StartInfo.FileName = Application.StartupPath & "\ffmpeg.exe" proc1.StartInfo.Arguments = String.Format(" -I " & "C:\V.mp4" & " -I " & "C:\M.wav c:\final.mp4") proc1.StartInfo.UseShellExecute = False proc1.StartInfo.WindowStyle = ProcessWindowStyle.Hidden proc1.StartInfo.RedirectStandardInput = True proc1.StartInfo.RedirectStandardOutput = True proc1.StartInfo.CreateNoWindow = True proc1.Start()
Now I need to know when this process is done. I've tried this:
If proc1.HasExited Then Kill("C:\V.mp4") Kill("C:\M.wav") End if
But sometime is points to Kill("C:\V.mp4") and it says its can't delete this file because another process is busy with this file.
Anyone knows how I can solve this problem?