By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,800 Members | 1,404 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,800 IT Pros & Developers. It's quick & easy.

Check whether file exist in computer, ask for help!

P: 48
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.
Mar 25 '07 #1
Share this Question
Share on Google+
4 Replies


Dököll
Expert 100+
P: 2,364
Greetings, Kuzure!

Here is what I found through Dev Fusion:

http://www.developerfusion.co.uk/show/4264/

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

Dököll
Mar 25 '07 #2

SammyB
Expert 100+
P: 807
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.
Expand|Select|Wrap|Line Numbers
  1.     Dim sFileSpec As String
  2.     sFileSpec = "C:\Documents and Settings\Sam\My Documents\Test.txt"
  3.     If Dir(sFileSpec) = "" Then
  4.         MsgBox "Test.txt does not exist"
  5.     End If
Mar 25 '07 #3

Expert 5K+
P: 8,434
In VB6 and VBA you use the Dir function. ...
Plus, if the other solution you tried, which didn't work, was using the FileSystemObject, then to make it work you probably need to add “Microsoft Scripting Runtime” in References, under your Project menu.
Mar 25 '07 #4

P: 48
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.
Expand|Select|Wrap|Line Numbers
  1.     Dim sFileSpec As String
  2.     sFileSpec = "C:\Documents and Settings\Sam\My Documents\Test.txt"
  3.     If Dir(sFileSpec) = "" Then
  4.         MsgBox "Test.txt does not exist"
  5.     End If

Thanks, sammyb.

Best Regards.
Mar 26 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.