Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

  • Leaders
Posted
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.
[sIGPIC]e[/sIGPIC]
Posted

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.

 

Hate to be too critical' date=' 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.[/quote']
  • Leaders
Posted
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.
[sIGPIC]e[/sIGPIC]

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...