Vb.net application - progress update screen

T

tedqn

I have simple vb application that loops through a list of filename and
perform a System.IO.File.Copy from one server to another. I have a
readonly textbox where I append messages showing what's going on. ie.

Processing ..
Copy \\Server1\file1 to \\Server2\file1 ... Done
Copy \\Server1\file2 to \\Server2\file2 ...

The copy process is slow for each file copy and the TextBox doesn't
show the messages until the whole program finished running. Is there a
way to make the TextBox render the partial result for each copying?
 
1

1388-2/HB

In your loop that is copying files, try calling the Refresh method of the
TextBox.

TextBox.AppendText("Processing .." & vbcrlf)

For Each oFile as File in MyListOfFiles

TextBox.AppendText("I'm coping stuff ... ")
TextBox.Refresh

oFile.Copy ...

TextBox.AppendText("Done" & vbcrlf)

Next

Or move your file copying to a seperate thread.
 
Z

zacks

I have simple vb application that loops through a list of filename and
perform a System.IO.File.Copy from one server to another. I have a
readonly textbox where I append messages showing what's going on. ie.

Processing ..
Copy \\Server1\file1 to \\Server2\file1 ... Done
Copy \\Server1\file2 to \\Server2\file2 ...

The copy process is slow for each file copy and the TextBox doesn't
show the messages until the whole program finished running. Is there a
way to make the TextBox render the partial result for each copying?

To ensure that screen updates are reflected as soon as possible, put
an:

Application.DoEvents

inside the copy loop.
 
T

tedqn

Great. Application.DoEvents did just fine. I haven't tried the
TextBox.Refresh method but thanks too.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top