quarta-feira, 21 de novembro de 2007

FileExists()

Checa se um arquivo existe.
O FileName pode ser um caminho absoluto ou relativo.

Function FileExists(ByVal FileName)

On Error Resume Next
If Mid(FileName, 2, 1) <> ":" Then
FileName = Server.MapPath(FileName)
End If
On Error GoTo 0

Dim fso
Set fso = Server.CreateObject("Scripting.FileSystemObject")
FileExists = fso.FileExists(FileName)
Set fso = Nothing

End Function

Nenhum comentário: