0

I need to know if a file exists, using Visual Basic 6 (not VB.NET). So far, I have this, as gleaned from a few different snippets I googled up:

If Len(Dir("C:\frogs\dogs.txt")) > 0 Then
    MsgBox "File Found!"
Else
    MsgBox "File Does Not Exist!"
End If

That's it. The whole script. Doesn't work. When I run it, I get "Type Mismatch: 'Dir'" What am I doing wrong?

This answer appears to be for a later version of VB? Maybe it's relevant?

Thanks for any help.

Community
  • 1
  • 1
crowhill
  • 2,398
  • 3
  • 26
  • 55
  • 1
    I've see this happen when you have something like `Dim Dir` in your app or is this VBScript? – Jim Hewitt Sep 19 '16 at 18:42
  • That's the entire script. There is no app. I'm not completely sure about the VB nomenclature though, so maybe I don't understand the question? – crowhill Sep 19 '16 at 19:08
  • 3
    VbScript doesn't have the `Dir`command. Take a look at [this](http://stackoverflow.com/questions/3031497/how-to-verify-if-file-exist-with-vb-script). – Jim Hewitt Sep 19 '16 at 19:22

0 Answers0