Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

FileListBox behavior using Directory property pointed to network drive

FileListBox behavior using Directory property pointed to network drive

FileListBox behavior using Directory property pointed to network drive

When I use a FileListbox set its Directory property to a network path, in IDE design the proper files are listed from my network drive but during runtime the Filelistbox defaults back to path of the exe's location. This also seems to happen with most components ie. DirectoryListBox as well.

I also set on FormCreate a SetCurrentDir('\\Mynetwork\Target$\FileFolder') again this seems to work in the design IDE perfectly, but not at runtime. My FileListBox again defaults to its 'Debug' actual directory.

I'm missing something rather basic, how can I set the directory property to take effect at runtime? I've got a workaround, by copying and running the program from the network drive but this isn't ideal.


RE: FileListBox behavior using Directory property pointed to network drive

If I'm not missing something somewhere, these are very old Windows 3.1 era controls. You can set these things on run-time, but you have to have a TDriveComboBox, TDirectoryListBox, and TFileListBox present and all these things linked together in order for them to work as one would generally expect in selecting something on runtime. Absent these inputs, they will default to the location of the executable. Absent the linkage, you can set them by:


DriveComboBox1.Drive := 'D';
DirectoryListBox1.Drive := 'D';
DirectoryListBox1.Directory := 'FILES1';
FileListBox1.Drive := 'D';
FileListBox1.Directory := '\FILES1'; 

Again the problem is that these are Windows 3.1 era controls (I use Delphi 3 and they were mostly deprecated THEN) and you really should be using methods more reflective of modern Windows. These calls introduce a more network-friendly way of doing things (your SetCurrentDir text is likely not going to work in these controls anyway). I cooked up a browse control to utilize SHBrowseForFolder at FAQ102-7233: Browse Directories and Files a long time ago that will demonstrate a large number of those newer functions, including those that point to the different system paths introduced from Windows 95 onward. Naturally once you locate a folder (network or otherwise), you should be able to use a standard TListBox with FindFirst/FindNext/FindClose.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close