Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7814149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T05:06:23+00:00 2026-06-02T05:06:23+00:00

Trying to use a loop to check if images exists however it is always

  • 0

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
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T05:06:26+00:00Added an answer on June 2, 2026 at 5:06 am

    You appear to be operating under the impression that the current folder context the your call to FileExists will 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.MapPath to resolve the path. This may work:

    if Not fs.FileExists(Server.MapPath("../i/"&sku&".gif")) then
    

    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:

    Dim path : path = Server.MapPath("/parentFolder/i") & "\"
    For i = LBound(arrRS, 2) to UBound(arrRS, 2)        
        sku = arrRS(0, i)        
        if Not fs.FileExists(path & sku & ".gif") Then        
            response.write Server.HTMLEncode(sku) & " does not exist<br>"        
        end if        
    next    
    

    Where “parentFolder” is the absolute path from the site root.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello i'm trying to use a do-while loop to check the input and repeat
I'm trying to use Linq to loop through all fonts in the %windir%\Fonts folder
I'm trying to use a foreach loop for an array of objects. Inside of
I'm trying to use the foreach loop in an Ant script but I get
I'm trying to use a cursor loop in MYSQL, but it's not working. I've
I'm trying to use openmp to multithread a loop through std::set. When I write
I'm trying to use a for line in data: loop to assign the first
I am trying to check for ascending order in this array But not sure
I am trying to use an 'if' condition to check whether a location for
I have a class that inherits from UIView However when trying to use the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.