HOWTO compare recordset with a name of a phisical file

Discussion in 'ASP General' started by Emilio Mala, Jul 13, 2004.

  1. Emilio Mala

    Emilio Mala Guest

    Hello everybody!
    If you could help he, I appreciate... thanks!
    Lets go to the problem:

    - I need compare the recordset from a database and check if the file
    exists in a directory.
    If exists, I show a picture, case not, I dont show....

    Sample:
    The result from a recordset was "hawai.jpg"
    Then I need to check if the file exists in a directory located in
    /images/countries/...
    IF exists I show the image
    IF NOT I show the message "Sorry, this country doesnt have a picture in
    the directory."
    Thanks in advance!
    Best Regards!
    Emilio



    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Emilio Mala, Jul 13, 2004
    #1
    1. Advertising

  2. Emilio Mala

    Bullschmidt Guest

    To see if a file exists:
    Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
    If objFSO.FileExists(MyFilenameVar) Then...

    And here are some FSO resources:

    FileSystemObject
    http://www.4guysfromrolla.com/webtech/faq/faqtoc.shtml#FileSystemObject
    5-part FAQ

    Using the FileSystemObject for Web Site Maintenance, Part 2 - 9/14/1999
    http://www.4guysfromrolla.com/webtech/091499-1.shtml

    Best regards,
    J. Paul Schmidt, Classic ASP Web Designer
    http://www.Bullschmidt.com
    Classic ASP Design Tips, ASP Web Database Demo, ASP Bar Chart Tool...


    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Bullschmidt, Jul 14, 2004
    #2
    1. Advertising

  3. Emilio Mala

    Alex Kail Guest

    Use this function. The file name must be the path in which it resides
    on the machine, not the absolute or relative paths (ie:
    c:\images\countrie\hawai.jpg).

    Function FileExist(strFileName)

    'Declare
    Dim fso
    Set fso = CreateObject("Scripting.FileSystemObject")

    'Functions returns whether or not the file exists
    FileExist = fso.FileExists(strFileName)

    'Housekeeping!
    Set fso = Nothing

    End Function

    Here's an example on how I use it:

    If FileExist(Server.MapPath("images\countries") & "\hawai.jpg") = True
    Then
    'This file exists
    Else
    'This file does not exist
    End If
     
    Alex Kail, Jul 14, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Felix McAllister
    Replies:
    6
    Views:
    468
    Felix McAllister
    Sep 16, 2003
  2. Phoe6
    Replies:
    3
    Views:
    700
    dwelch91
    Jul 18, 2006
  3. Richard
    Replies:
    1
    Views:
    347
    Victor Bazarov
    Aug 13, 2005
  4. Hung Huynh
    Replies:
    8
    Views:
    348
    Bob Barrows
    Sep 24, 2003
  5. Dr.Gizmo

    recordset name poblem

    Dr.Gizmo, Apr 23, 2004, in forum: ASP General
    Replies:
    3
    Views:
    127
    dlbjr
    Apr 24, 2004
Loading...

Share This Page