|
-
Aug 20th, 2000, 07:35 PM
#1
Thread Starter
Lively Member
hi was hoping someone can help me out, I want to be able to search if a certain directory exists. I want to be able to search all local drives and even those that are networked. And is there a way to count the number of files in a certain directory besides using a filelistbox ?
Thanx i appreciate the help = )
-
Aug 20th, 2000, 07:41 PM
#2
Q2: And is there a way to count the number of files in a certain directory besides using a filelistbox ?
Code:
Dim FileFinder
FileFinder = Dir("C:\Windows\*.*")
Do Until FileFinder = ""
List1.AddItem LCase(FileFinder)
FileFinder = Dir
Loop
MsgBox "There are " & List1.ListCount & " files in the Windows directory."
-
Aug 21st, 2000, 02:45 AM
#3
transcendental analytic
Code:
DirectoryExists=cbool(len(dir("C:\windows",vbDirectory)))
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Aug 21st, 2000, 03:50 AM
#4
Fanatic Member
Last time I needed to list the storage devices (i.e. harddrives, nw drives, cdroms, etc) it was about a half a megabyte (slight exaguration) of code, all lowlevel API stuff. I have (conveniently) not needed to enumerate these device since... But there's probably a more efficient way of doing it.
I was doing it for a window shell I never finished, and I needed to not only enumerate the devices, but also set an appropiate icon for the device's type. I don't have the code off hand, but one of the other friendly folks in here might be able to help.
Just my two cents.
-
Aug 22nd, 2000, 07:19 AM
#5
Thread Starter
Lively Member
Originally posted by kedaman
Code:
DirectoryExists=cbool(len(dir("C:\windows",vbDirectory)))
thanx for the tip! i was hoping you could explain how the code works because i'm a little confused. Thanx again!
-
Aug 22nd, 2000, 07:21 AM
#6
Thread Starter
Lively Member
Thanks for all the help guys! i greatly appreciate it!
-
Aug 22nd, 2000, 07:36 AM
#7
Fanatic Member
Originally posted by gin
Originally posted by kedaman
Code:
DirectoryExists=cbool(len(dir("C:\windows",vbDirectory)))
thanx for the tip! i was hoping you could explain how the code works because i'm a little confused. Thanx again!
Dir(Path, vbDirectory) just returns a string if the directory exists. Len(anyString) works out the length oif a string. CBool converts a number to a boolean expression. So if Len(dir("C:\windows,vbDirectory")) = 0 (it doesn't exist) then it returns false. If it is <> 0, then it reurns true.
-
Aug 22nd, 2000, 03:04 PM
#8
transcendental analytic
Originally posted by V(ery) Basic
Originally posted by gin
Originally posted by kedaman
Code:
DirectoryExists=cbool(len(dir("C:\windows",vbDirectory)))
thanx for the tip! i was hoping you could explain how the code works because i'm a little confused. Thanx again!
Dir(Path, vbDirectory) just returns a string if the directory exists. Len(anyString) works out the length oif a string. CBool converts a number to a boolean expression. So if Len(dir("C:\windows,vbDirectory")) = 0 (it doesn't exist) then it returns false. If it is <> 0, then it reurns true.
Dir is used to enumerate files and subdirectories in a directory, By passing the directory path it will start search that directory while it will continue to return all files and subdirectories if you omit the directory, until it returns "" which means that there are no more items to return, which is the case if you don't find the directory at all. Also by specifying vbdirectory it will filter everything exept directories.
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|