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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FileListBox behavior using Directory property pointed to network drive

Status
Not open for further replies.

Tony1l

Programmer
Dec 21, 2002
30
US
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.

Thanks
-Tony

 
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:

Code:
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 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.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top