Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 145
  • Last Modified:

How to access to a particular file in a drive?

I'd like to know how to access to a particular file in a drive.I know I'd have to make use of the drivelistbox and dirlistbox.But how to link it altogether to access to a particular file?
Right now,i can only access to C:
  • 2
1 Solution
If I understand correctly, you want to develop your own open/save dialog box kind of thing.

You require drivelist, dirlist, filelist.

Add the three controls. In change event of dir and drivelists, add the codes,

Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub

Private Sub Drive1_Change()
    Dir1.Path = Drive1.Drive
    File1.Path = Dir1.Path
End Sub


dir1.path & "\" & file1.filename

to retrieve the filename with full path.
VivienWAuthor Commented:
Yes,thank you adp1970.
Having done that, I want to access to a certain file from the directory and file list and use the contents of that file(say..a .txt file in this case) in my application. I would like to assign variables to some of the contents in the txt file.
How do I do that??
Sorry, your question is not clear to me. Do you want to restrict the type of file in the filelistbox? If so, Use file1.pattern = "*.txt"
or whatever you want eg. *.*, *.bat etc.

But you are saying you want to use the contents of that file, then you have to open the file, read from the file using Input statement or newer FSO model.


Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now