Check whether file exist in computer, ask for help!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kuzure
    New Member
    • Dec 2006
    • 48

    Check whether file exist in computer, ask for help!

    Dear friends,

    I need to use VB6 to check whether the file is existing in my computer. How can I do it?

    I had search this similar topic in this forum. Although I found one, thats not working at all. Perhaps, there is still other ways.

    Best Regards.
  • Dököll
    Recognized Expert Top Contributor
    • Nov 2006
    • 2379

    #2
    Greetings, Kuzure!

    Here is what I found through Dev Fusion:



    Hopefully this what you are looking for. Give it a whirl.

    Dököll

    Comment

    • SammyB
      Recognized Expert Contributor
      • Mar 2007
      • 807

      #3
      Originally posted by kuzure
      Dear friends,

      I need to use VB6 to check whether the file is existing in my computer. How can I do it?

      I had search this similar topic in this forum. Although I found one, thats not working at all. Perhaps, there is still other ways.

      Best Regards.
      In VB6 and VBA you use the Dir function. If you type Dir in your code & press F1, the help file will tell you how to use it. Here's a simple example.
      Code:
      	Dim sFileSpec As String
      	sFileSpec = "C:\Documents and Settings\Sam\My Documents\Test.txt"
      	If Dir(sFileSpec) = "" Then
      		MsgBox "Test.txt does not exist"
      	End If

      Comment

      • Killer42
        Recognized Expert Expert
        • Oct 2006
        • 8429

        #4
        Originally posted by SammyB
        In VB6 and VBA you use the Dir function. ...
        Plus, if the other solution you tried, which didn't work, was using the FileSystemObjec t, then to make it work you probably need to add “Microsoft Scripting Runtime” in References, under your Project menu.

        Comment

        • kuzure
          New Member
          • Dec 2006
          • 48

          #5
          Originally posted by SammyB
          In VB6 and VBA you use the Dir function. If you type Dir in your code & press F1, the help file will tell you how to use it. Here's a simple example.
          Code:
          	Dim sFileSpec As String
          	sFileSpec = "C:\Documents and Settings\Sam\My Documents\Test.txt"
          	If Dir(sFileSpec) = "" Then
          		MsgBox "Test.txt does not exist"
          	End If

          Thanks, sammyb.

          Best Regards.

          Comment

          Working...