FileListBox not updating

bjwade62

Centurion
Joined
Oct 31, 2003
Messages
104
I'm using System.IO.File.Copy to copy a file to a folder. I have a FileListBox on my form that contains the files in that folder. The problem I'm having is that the FileListBox doesn't show the newly added file unless I change folders and then come back it.

I've tried FileListBox.Refresh and FileListBox.Update with no luck.

Any help out there?

Thanks,
Bernie
 
Hate to be too critical, but why are you using the FileListBox? It is there for VB6 compatability. Although it may be more work and might seem like re-inventing the wheel, I personally would suggest that you use a regular list box (or better yet, a list view) and populate it yourself. That way, you have complete control over the display and function of the control.
 
It does sound a bit like re-inventing the wheel. I never understood why MS took it out. However, the real issue is that it's an old app that I'm trying to convert to .NET and I was trying to save time. Thanks for the advise, when I have more time I'll probably do that.

marble_eater said:
Hate to be too critical, but why are you using the FileListBox? It is there for VB6 compatability. Although it may be more work and might seem like re-inventing the wheel, I personally would suggest that you use a regular list box (or better yet, a list view) and populate it yourself. That way, you have complete control over the display and function of the control.
 
Well, if it is an old app that you are converting then that would be a fair use of the legacy control. Microsoft deprecated it because the FileListBox is an old way of doing things, generally used from Windows 3 back to dos, though it can occasionally be seen in apps for Windows 95 and later, it is almost never used in professional applications today. The fact is that it's functionality is very simple to reproduce: Get a DirectoryInfo object for the folder you want to list files from, use that to get a list of files and loop through them, adding them to a ListBox. And since it is seldom used anymore and tends to be much more difficult to use than an open file dialog I personally think that deprecation is appropriate. Regardless, there should be a method to refresh the contents of the control.
 
Back
Top