Link to home
Start Free TrialLog in
Avatar of denam
denam

asked on

VBScript FileExists

I want to check to see if a file on a remote directory exists using vbscript.  My code is not working
Avatar of denam
denam

ASKER

This is the code I'm using.  It's in an ASP file.  GetSpecialFolder(0) is tacking
C:WINNT to the front of the path.  What am I doing wrong?

<%
        Dim objFs
        Dim sFilePath

        strString = request.querystring ("att_id")
        sJPG = strString & ".jpg"
        Set objFs = CreateObject("Scripting.FileSystemObject")
        sFilePath = objFs.GetSpecialFolder(0) & "\images\members\" & sJPG

        strRequest = "Select * from Members where id = " & strString
        Set rsAtt = TIADB.Execute(strRequest)
%>
<%
       do while not rsAtt.eof

         if objFs.FileExists(sFilePath) then
           response.write ("<h3>File Path: " & sFilePath & " EXISTS</h3>")
         else
           response.write ("<h3>File Path: " & sFilePath & " NOT FOUND</h3>")
         end if
%>
Avatar of denam

ASKER

This code works - it's looking for a file on my local machine.  I just
need to figure out how to do this for a remote file.
<%      
        Dim objFs, sFilePath
        Set objFs = CreateObject("Scripting.FileSystemObject")
        sFilePath = objFs.GetSpecialFolder(0) & "\clock.avi"

         if objFs.FileExists(sFilePath) then
           response.write ("<h3>File Path: " & sFilePath & " EXISTS</h3>")
         else
           response.write ("<h3>File Path: " & sFilePath & " NOT FOUND</h3>")
         end if
%>
denam

  Have you found an answer to this yet?, I've been trying to do
this also.  Thought of creating an array of files on remote that
I know are there then comparing file with that list, but I know
there has to be better way.  Thanks for any info on this.
What do you mean by "my code is not working" ?
Have an error message ?
How do you access to the remote computer ? (http, mapped drive, ...)
Have you got List permission on the remote computer ?

 Eloi.
Speaking for myself and not denude,
I am accessing by http, with list permission by ftp.
What I'm tryng to do ,in VBscript, is when someone is on my webpage they can click to veiw imgfiles in Public dir on server(that is no problem, can do that) but want to precheck if they exist in that dir.
the "CreateObject("Scripting.FileSystemObject")" looks at the local machine not the server.
There is no error for me, function just looks in wrong place.
Thanks for any input.









Avatar of denam

ASKER

jbil, the problem you describe is exactly the problem i've encountered.
so far, I've gotten no satisfactory answer to the question.
ASKER CERTIFIED SOLUTION
Avatar of khaled022498
khaled022498

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial