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

file existing or not

Status
Not open for further replies.

dorling

Technical User
Mar 25, 2004
80
GB
hi there,

this is a very easy question so here goes!!!

i basic need to find out if a file existing or not?

i need to do this using the if command

thanks in advance

Jonathan D
 
Code:
Function ReportFileStatus(filespec)
   Dim fso, msg
   Set fso = CreateObject("Scripting.FileSystemObject")
   If (fso.FileExists(filespec)) Then
      msg = filespec & " exists."
   Else
      msg = filespec & " doesn't exist."
   End If
   ReportFileStatus = msg
End Function
 
how do i call this function

thanks in advance

Jonathan D
 
Throw the function somewhere... either in the top of the page or if you have a include file for functions, in there...

Call it by doing something similar..
Code:
Response.Write ReportFileStatus("C:\boot.ini")

Note, you'll need to use the server's pathing. The file you're checking has to be on the server, so you'll need to put in whatever path is necessary to get to the file, and if you know all the files are going to be in the same location, you can prebuild the path and have the "filespec" be just the file name itself and then concatenate it with the path before running it through the FSO.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top