Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to find if a file exists

Status
Not open for further replies.

Craftor

Programmer
Feb 1, 2001
420
0
0
NZ
I need to find out of a certain file (designated by the user) exists so that if it doesn;t, an error is raised and the program's execution is halted.

How do I find if this file exists?
 
HI

With Dir function you can know if the file exist

Dir[(pathname[, attributes])]
___________________________
Hugues Gauthier
Programmeur Analyste
Progitech
---------------------------
hugues_gauthier@hotmail.com
 
I Give users a Common Dialog to avoid errors.
 
Hi all

Have found another way to do this, in case anyone is interested:

dim FS as Scripting.FileSystemObject
Set FS = New Scripting.FileSystemObject

if FS.FileExists("C:\MyDir\Myfile.txt") then
end if

X-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top