Results 1 to 4 of 4

Thread: finding whether a folder exists or not

  1. #1

    Thread Starter
    Lively Member muralidhary's Avatar
    Join Date
    Aug 2001
    Location
    Chennai
    Posts
    89

    Unhappy finding whether a folder exists or not

    hello
    i want to find whether a folder exists or not
    how can i do
    please help me

  2. #2
    Lively Member venom8's Avatar
    Join Date
    Jul 2001
    Location
    Quezon City, PHIL.
    Posts
    87
    try this :

    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Form_Load()
    4.  
    5. Dim myFolder As String
    6.  
    7.  
    8. myFolder = Dir$("C:\SampleFolder\")
    9.  
    10. If myFolder = "" Then
    11.     MsgBox "Folder does not exist!"
    12. ElseIf myFolder <> "" Then
    13.     MsgBox "Folder Exist!"
    14. End If
    15.  
    16. End Sub
    You never become a failure, unless you quit on trying!!!

  3. #3

    Thread Starter
    Lively Member muralidhary's Avatar
    Join Date
    Aug 2001
    Location
    Chennai
    Posts
    89

    Exclamation problem with code

    the above code is working but
    it is working if the folder contains any file
    otherwise the
    function is returning empty string
    the i am not able to verify
    can u help me

  4. #4
    Fanatic Member Kaverin's Avatar
    Join Date
    Oct 2000
    Posts
    930
    VB Code:
    1. If Dir$("c:\somedir", vbDirectory) <> "" Then
    2.    'directory exists
    3. Else
    4.    'directory doesn't exist
    5. End If
    That should work even if the dir has no files in it, since you're explicitly looking for the dir.
    I'm baaaack...
    VB5 Professional Edition, VC++ 6
    Using a 1 gHz Thunderbird, 256 mb RAM, 40 gb HD system with Win98se

    I feel special because I finally figured out how to loop midis: Post link
    I'm a fanatic too

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