IIS6 + FSO.FileExists() + Not working

E

Eric

Hi Friends
Below is the code tht i m testing..I m trying to run on
windows 2003 server, iis 6.0.
I have given full rights IUSR_ to C:/test folder but also
checked files many times
but It always says fild not found..
cant understand whats going on? I tried with fowardslash
and backslas both but neither is working...There is no
firewall on server.

Filename = "C:/test/sample.txt"
Dim FSO
set FSO = server.createObject
("Scripting.FileSystemObject")
If FSO.FileExists(Filename) Then
Response.write "File found"
Else
Response.Write "File not found"
End If
Set FSO = nothing

Any help would be appreciated...
Thanx
Eric
 
R

Roland Hall

in message : Hi Friends
: Below is the code tht i m testing..I m trying to run on
: windows 2003 server, iis 6.0.
: I have given full rights IUSR_ to C:/test folder but also
: checked files many times
: but It always says fild not found..
: cant understand whats going on? I tried with fowardslash
: and backslas both but neither is working...There is no
: firewall on server.
:
: Filename = "C:/test/sample.txt"
: Dim FSO
: set FSO = server.createObject
: ("Scripting.FileSystemObject")
: If FSO.FileExists(Filename) Then
: Response.write "File found"
: Else
: Response.Write "File not found"
: End If
: Set FSO = nothing

<%@ Language=VBScript %>
<%
Option Explicit
Response.Buffer = True
Const strPath = "c:\test\"
Const filename = "sample.txt"

function exists(filespec)
Dim fso, msg
Set fso = CreateObject("Scripting.FileSystemObject")
If (fso.FileExists(strPath & filename)) Then
msg = filespec & " found."
Else
msg = filespec & " not found."
End If
exists = msg
end function
Response.Write(exists(strPath & filename))
%>

HTH...

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
 
R

roger

Filename = "C:/test/sample.txt"
Dim FSO
set FSO = server.createObject ("Scripting.FileSystemObject")
If FSO.FileExists(Filename) Then
Response.write "File found"
Else
Response.Write "File not found"
End If
Set FSO = nothing

The code searches for a file on the *server*.

Are you searching for a file on your client machine?
 
E

Eric

i m looking for file on the server..
-----Original Message-----

The code searches for a file on the *server*.

Are you searching for a file on your client machine?


--
roger


.
 
R

Roland Hall

in message : what changes u have done?
: whts the reason???
: Eric

Eric...

I never use c:/ anything since it doesn't make sense to me. / is a virtual
path or parameter and \ is a physical path. You're referencing a physical
path. While / may be supported, this is Windows, not *nix. So, I was not
sure if that was correct and I gave you a sample that does work. If it
still does not work, then you need to check your security rights at the file
system level, anonymous access is enabled and the anonymous user that has
those rights is the one you're using. Also, you do not need full rights.
Modify is all you need. When assigning security rights at the file system
level you should understand the difference and only apply what is needed and
not all inclusive.

HTH...

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
 
M

mrbester

roger said:
In that case I think it must be an IIS 6
security thing, because your code
works fine here.

I had this problem as well, after migrating a website from IIS4 (don't
ask) to IIS6.
Turns out that using FileMon
(http://www.sysinternals.com/ntw2k/source/filemon.shtml) gave me the
answer: ACCESS DENIED
After that it was a case of allowing w3wp.exe (in its security context)
permission to get to the file. It's probably NETWORK SERVICE that needs
adding at the file/folder level.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,733
Messages
2,569,440
Members
44,831
Latest member
HealthSmartketoReviews

Latest Threads

Top