Link to home
Start Free TrialLog in
Avatar of dgb001
dgb001

asked on

Get default drive and list files and files in subfolders

Hi,

Without using a DriveBox or FileList box, and also without using Microsoft's new filesysinfo dll (or whatever it's called, which ships with VB6) I want to be able to ascertain the users default drive, and get the name of each *.bmp file in that drive and in all subfolders.

Many thanks,
Dave
Avatar of SiM99
SiM99

use the Dir$() function... look it up in the help and it will show you what to do with it.

Sorry for the lack of input (no example) but the computer i'm on doesn't have VB installed on it.

The idea is to do a loop, using Dir() to get a filename, checking the return type to see ie it's a DIR or FILE, then if it's a file, do

if (right(filename, 4) = ".bmp") then

again, sorry that i cannot give an example, but i could do if you want me to, just say so :)
Avatar of dgb001

ASKER

OK, thx, I'll take a look and let you know.

Cheers,
Dave
ASKER CERTIFIED SOLUTION
Avatar of Vbmaster
Vbmaster

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dgb001

ASKER

Ok, let me have a read and play with it and I'll get back to you.

Many thx,
Dave
Avatar of dgb001

ASKER

Hi,

Just a couple of things:

a) I seem to get a "User-defined type not defined" on the first line when it tries to Dim clsFile

b) I notice that you defaulted it to use C:\ - is there a way to find out if that is indeed the default drive ?

Many thx,
Dave
you need the class file called clsFile
Oops remove the line..

  Dim File As New clsFile

and change the function call from..

  Call File.ListFiles("C:\", x, True, True, "*.bmp")

to..

  Call ListFiles("C:\", x, True, True, "*.bmp")
To get the current drive you can use the CurDir variable, where the current drive is Left$(CurDir, 3)
Avatar of dgb001

ASKER

Okey dokey - let me play around and I'll get back to you.

Thx for your help,
Dave
Avatar of dgb001

ASKER

Thx,
Dave