Trying to use a loop to check if images exists however it is always returning false. I am sure I am doing something simple and stupid but here is the code:
dim fs, sql_except
set fs=Server.CreateObject("Scripting.FileSystemObject")
if Not rs.eof then
arrRS = rs.GetRows(30,0)
set rs = nothing
If IsArray(arrRS) Then
For i = LBound(arrRS, 2) to UBound(arrRS, 2)
sku = arrRS(0, i)
if (fs.FileExists("../i/"&sku&".gif")=false) Then
response.write sku&"does not exist<br>"
end if
next
end if
erase arrRS
end if
set fs=nothing
You appear to be operating under the impression that the current folder context the your call to
FileExistswill assume is the physical folder containing the ASP script being executed. This is not so, it most likely will be “C:\windows\system32\inetsrv”. You are also using URL path element separator/where FileExists is expecting windows physical path folder separator\.You need to use
Server.MapPathto resolve the path. This may work:However you may run in to trouble with the parent path “..”, this may not be allowed for security reasons. This might be a better approach:
Where “parentFolder” is the absolute path from the site root.