Computing.Net > Forums > Programming > if file exists? (VB)

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

if file exists? (VB)

Reply to Message Icon

Name: DAVE
Date: June 30, 2003 at 14:18:19 Pacific
OS: Windows XP
CPU/Ram: AMD Athlon XP 1700+ / 256
Comment:

im trying to make it so if a certain file exists, the program runs another program. ive got the running the other program part, but i have no clue how to make VB check for that first file. can someone give me some code or explain how i would go about doing this?

Dave



Sponsored Link
Ads by Google

Response Number 1
Name: Zad01
Date: June 30, 2003 at 20:24:32 Pacific
Reply:

if dir$("path\filename"""then ' If File Exists [ie. 
path\filename = "c:\windows\calc.exe"]

  Run Program 1

else ' If File Dose Not Exists

  Run Program 2

endif

Hope this Helps


0

Response Number 2
Name: A Certain TH
Date: July 2, 2003 at 04:42:12 Pacific
Reply:

The above is the sensible way.

Another way is to jump into a boolean function which tries to open the file directly. Put an error handler on this function. Then the function either returns success or failure and you have the file open and ready to use if it was successful.

Tom


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


Using an outside class? Accessing data directly i...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: if file exists? (VB)

FTP check to see if file exists www.computing.net/answers/programming/ftp-check-to-see-if-file-exists/14691.html

Batch If (file exists) www.computing.net/answers/programming/batch-if-file-exists/20321.html

VBS if any file exists www.computing.net/answers/programming/vbs-if-any-file-exists/19801.html