|
Why relative filespecs may not work in ASP
Even though the helpfile states you can use relative directory paths with FileSystemObject
objects, you probably encountered an error if you tried to use them in an ASP path. That's because
the directory that contains the ASP page doesn't become the current directory, as far as the FileSystemObject
is concerned. To illustrate, run the following VBScript code in an ASP page:
<%Set FileObject = Server.CreateObject("Scripting.FileSystemObject")
filespec="\test.jpg"
CurrDir = FileObject.GetAbsolutePathName(".")
response.write "Using CurrDir: " & CurrDir & filespec & "<br>"
if FileObject.FileExists(filespec) then
response.write "[CurrDir] File Found<br>"
else
response.write "[CurrDir] No File found<br>"
end if
response.write "Using MapPath: " & Server.MapPath(filespec) & "<BR>"
if FileObject.FileExists(Server.MapPath(filespec)) then
response.write "[MapPath] File Found<br>"
else
response.write "[MapPath] No File found<br>"
end if
Set FileObject = Nothing%>

|