Thread: Check for file

    #1
  1. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Location
    Buffalo, NY
    Posts
    156
    Rep Power
    12

    Check for file


    Hello,
    What I'm TRYING (and failing) to do is very simple, check a directory for XXX file.

    I know the name of the file, and I know the directory. I don't want to do a listing of the directory and then check the list, that would be a huge load on the server...

    <cfset xxx = "somefile">
    <cfset yyy = "someotherfile">

    <cfif XXX file exists>
    <cffile copy XXX to YYY>
    <cfelse>
    Sorry the file you are trying to copy does not exist.
    </cfif>


    I have the cffile line of code, but not the CFIF statement. Any help would be greatly appreciated!

    -Matt
    Forget Milk!
    Gotspy?

    www.gotspy.com
  2. #2
  3. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,273
    Rep Power
    968
    Why not use fileExists()?

    <cfif fileExists( absolute_path_to_file )>
    ...
    </cfif>
  4. #3
  5. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Location
    Buffalo, NY
    Posts
    156
    Rep Power
    12

    Talking


    DING! Pull me out of the oven! I'M DONE!!!

    Thanks kiteless, I knew there HAD to be some very simple way to do this... I searched through my code book and the internet for a few hours yesterday...

    Thanks!
    Forget Milk!
    Gotspy?

    www.gotspy.com

IMN logo majestic logo threadwatch logo seochat tools logo