|
-
Aug 15th, 2021, 05:02 PM
#1
Thread Starter
Lively Member
Help! I want to send process output to textbox in realtime.
I have a program that processes a collection of files, places them in a folder, and then compresses that folder using a CLI-based exe. Works fine.
Problem is, during the compression, despite redirecting the process output to a textbox, I can't see what it's doing until it's done:
Code:
Private Sub ZipFolder()
Dim sOutput As String
Dim oProcess As New Process
' Compress/Zip:
With oProcess.StartInfo
.FileName = Chr(34) & strLaunchDir & "\7za.exe" & Chr(34)
.Arguments = "a -tzip " & Chr(34) & Path.GetDirectoryName(strCTKPath) & "\" & lblFolderName.Text & "\Folders\" & lblFolderName.Text & ".zip" & Chr(34) & " " & Chr(34) & Path.GetDirectoryName(strCTKPath) & "\" & lblFolderName.Text & "\Folders\" & lblFolderName.Text & Chr(34) ' Command format: "7za.exe a [zip switch] "Dest" "Src"
.UseShellExecute = False
.RedirectStandardOutput = True
.CreateNoWindow = True ' use this if you don`t want to see the cmd window.
End With
oProcess.Start()
Using oStreamReader As System.IO.StreamReader = oProcess.StandardOutput
sOutput = oStreamReader.ReadToEnd()
tbxOutput.AppendText(sOutput) ' Append output w/o reassigning/printing the entire contents over & over. "Append" forces window to scroll.
Application.DoEvents() ' This gives labels time to update so it doesn't freeze during the process.
tbxOutput.Refresh() ' Do this to update window in realtime.
End Using
oProcess.WaitForExit()
oProcess.Close()
oProcess.Dispose()
End Sub
I thought "tbxOutput.Refresh()" would be enough, but clearly it isn't.
Is there a way to show the process output so I can see the compression taking place in real-time? TIA
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|