Results 1 to 8 of 8

Thread: newbie help

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2000
    Posts
    74

    Smile

    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 = )

  2. #2
    Guest
    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."

  3. #3
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    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.

  4. #4
    Fanatic Member
    Join Date
    Jun 1999
    Location
    California, USA
    Posts
    662
    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.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Jun 2000
    Posts
    74

    Smile

    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!

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Jun 2000
    Posts
    74

    Talking

    Thanks for all the help guys! i greatly appreciate it!

  7. #7
    Fanatic Member
    Join Date
    Apr 2000
    Location
    Whats a location?
    Posts
    516
    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.
    Courgettes.

  8. #8
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    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
  •  



Click Here to Expand Forum to Full Width