Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Searching Through Files

Status
Not open for further replies.

stathread

Programmer
Jan 17, 2006
38
US
Ive created a recursive copy and when its iterating through the files I have the filenames shown in a textbox. My problem is however that when I click outside of the form while it is running the process throws and error and is caught. The reason behind this is how can I refresh a form that is not active I suppose. Is there another way to display the filenames without the form going blank on me?

Thanks.

//in loop
PathScroller.Text=z.ToString();//z=filename
Form1.ActiveForm.Refresh()
 
Are you updating the form on a thread other than the one that created it?

This is a Win32 limitation, and to get around it, use code like this:
Code:
private delegate void FSDelegate(string currentFile);

public void UpdateFileStatus(string currentFile)
{
   if (this.InvokeRequired)
   {
       this.BeginInvoke(new FSDelegate(UpdateFileStatus),
          new Object[] {currentFile});
       return;
   }

   PathScroller.Text = currentFile;
}
Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top