Results 1 to 7 of 7

Thread: Seeing if a folder exists

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2000
    Location
    Philadelphia
    Posts
    123

    Question

    This should be an easy question for you guys...

    At the beginning of my program, I want to see if a folder exists, and if it does, I want to delete it. Dir() does not seem to be working. It is still drawing a "" when I know the folder exists. This is my code:

    If Dir(App.Path & "\temp") <> "" Then RmDir (App.Path & "\temp")

    How do I get this to work?
    VB6 & VC++6 Pro (SP4), Java (Sun JDK)

  2. #2
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    Try this:
    Code:
    If Dir(App.Path & "\temp", vbDirectory) Then
    Or you could just try to remove the folder and catch the error if it doesn't exist:
    Code:
    On Error Resume Next
    RmDir App.Path & "\Temp"
    Good luck!

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Aug 2000
    Location
    Philadelphia
    Posts
    123
    Worked great, Joacim. Thank you.
    VB6 & VC++6 Pro (SP4), Java (Sun JDK)

  4. #4
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Joacim, you get an typemismatch with just a string
    Code:
    If len(Dir(App.Path & "\temp", vbDirectory)) Then
    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.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Aug 2000
    Location
    Philadelphia
    Posts
    123
    Kedaman's right. I used

    Code:
     If Dir(App.Path & "\temp", vbDirectory) <> "" Then
    VB6 & VC++6 Pro (SP4), Java (Sun JDK)

  6. #6
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    Yes of course! This is what's happening when you type the code directly into the post.

  7. #7
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Hehe, which usually happens to me but obviously it happens to everyone
    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