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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FSO if file exists issue

Status
Not open for further replies.

DebbieDavis

Programmer
Jun 7, 2002
146
US
Hi there, I am trying to delete a file like this:

Code:
Set fso = CreateObject("Scripting.FileSystemObject")
Set fileObject = fso.GetFile("\\server\file.txt")
fileObject.Delete

It works great EXCEPT when the file isn't there... How do I see if it exists first? I've tried:

Code:
Set fso = CreateObject("Scripting.FileSystemObject")
Set fileObject = fso.GetFile("\\server\file.txt")
if fso.fileExists(fileobject) then
fileobject.delete
end if

but it blows past it then I get an error because the file can't be found. Any ideas? Thanks very much.

dd
 
fso.fileExists("\\server\file.txt")

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

zen.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top