<% set fs=Server.CreateObject("Scripting.FileSystemObject") If fs.FileExists("index.stm") Then CODE HERE Else CODE HERE End If %>
The problem is this: fs.FileExists("index.stm") always evaluates to false, even though I'm staring at the file "index.stm" as I type. In fact, I can open the file just fine, using the OpenTextFile() method. Checking to see if the file even exists is the problem. Anybody have any ideas?
I simply want to verify the existance of a file on the server,
if the file Exists do something on the client side otherwise Stop executing and reload the main page (login).
To get the response of the FileExists I use a ShowModalWindow from a VBS call. The value returned works fine but only the FIRST time that it is called. Only if I restart the IE I get the correct response from FileExists. It seems a session related problem, infact the modal window has always the same session ID (unless IE is restarted). "Session.abandon" in the modal window code didn'T help.
I have been messing with FSO.FileExists for a while and have been looking into its limitations. On our server, we operate our directory in:
d:inetpubwwwrootintranet
and inside that directory is a VIRTUAL DIRECTORY by the name of employeeImages which maps to
otherserverfolder
So saying
d:inetpubwwwrootintranetemployeeImagesfile.jpg
IS the same thing as saying
otherserverfolderfile.jpg
The problem is, that when I set that path to a variable, called strPath and perform the following:
blnExists = FSO.FileExists(strPath)
it KEEPS returning as FALSE. So I had it output strPath. Sure enough it was the URL shown above. I cut and paste that into a window's location bar and boom, I'm taken RIGHT to the image.
So I'm thinking "Ok, FSO is a FILE SYSTEM OBJECT. Maybe it's limitations mean that it can only look at the local filesystem? Maybe it cannot see across a networked device? Maybe it cannot work with virtual directories?" I've done some looking around and cannot find any pages on limitations of FSO.
how to use FileExists to check to see if a file exists on a local server BUT what if I want to check if a file exists on a remote server (webserver)? If I enter "http://domainname/folder/image.jpg" it always returns false.
When a file is local to the ASP application, I can use the following code to test if the file exists:
Dim strFileName, blnFileExists, objFSO
strFileName = Server.MapPath( "MyFiles est.doc" )
Set objFSO = Server.CreateObject("Scripting.FileSystemObject") blnFileExists = objFSO.FileExists( strFileName ) Set objFSO = Nothing
But if "MyFiles" resides on another server and I set up a virtual directory in my ASP app to reference to it (e.g. "MyFiles est.doc" resolves to server2F$MyFilesest.doc), the code would return False even if the file exists on the other server.
The jist of what i want is the obj.FileExists (how it checks for a file on the server) for the client machine.
The client will be scanning something that will put a pdf file into a shared folder on their machine (it will be the same path for all clients). I need to get the code* to pull that file so that i can take the data on the pdf.
*Code doesn't have to be ASP. i'm up for ASP, VBScript, Javascript.
I have searched through the threads relating to FileExists, and have not found an answer (I did find one that dealt with using the FileExists method on a remote server, but that's not quite what I need to do.)
The script searches for all pictures in a particular folder on the server. The current script uses m:... as the path. The site will be transferred to a new host, and onto a shared server (so no more m:).
I am going crazy trying to figure out why the FileExists method of the FileSystem object returns false when the file passed to it DOES exist.
The FolderExists method of the same object recognizes the existence of the folder containing the files in question, but FileExists always returns false.