Results 1 to 4 of 4

Thread: Finding a file in a directory

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2001
    Location
    Lisbon, Portugal
    Posts
    69

    Question Finding a file in a directory

    Hi,

    How can I know if a file already exists in a directory?
    Rita Jaques

  2. #2
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    use Dir on it
    VB Code:
    1. If Len(Dir$("c:\winnt\win.ini"))>0 then
    2.     msgbox "Exists!"
    3. else
    4.     msgbox "Doesn't"
    5. end if

  3. #3
    Frenzied Member nishantp's Avatar
    Join Date
    Jan 2001
    Location
    Where you least expect me to be
    Posts
    1,375
    VB Code:
    1. Function FileExist(ByVal strPath As String) As Boolean
    2.     FileExist = Len(Dir(strPath)) <> 0
    3. End Function

    If you dont want to put in the full path every time and only check within 1 directory, before you call the function do this:
    VB Code:
    1. ChDir "C:\MyDir"
    You just proved that sig advertisements work.

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Mar 2001
    Location
    Lisbon, Portugal
    Posts
    69
    Thanks a lot.
    Rita Jaques

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