Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Verification if a file existe before that i try to delete it ?

Status
Not open for further replies.

FluFFy05

Programmer
Jul 4, 2000
19
CA
When i'd try to delete a file that not exist i have an error message and i'd like to find a solution to resolte this problem !

Thanx
Fluffy

Code for delete
<cffile action=&quot;delete&quot; file=&quot;#DestPhoto##nom_photo_suppl#&quot;>
 
Try:

<!-- Grab the directory -->
<CFDirectory ACTION=&quot;LIST&quot; NAME=&quot;GetPhotos&quot; DIRECTORY=&quot;#path#&quot;>

<!-- Loop thru the directory -->

<cfloop query=&quot;GetPhotos&quot;>
<cfif #GetPhotos.Name# IS &quot;#DestPhoto##nom_photo_suppl#&quot;>
<cffile action=&quot;delete&quot; file=&quot;#DestPhoto##nom_photo_suppl#&quot;>
</cfif>
</cfloop> John Hoarty
jhoarty@quickestore.com
 
There is alo a FileExists() function that will &quot;test&quot; whether a file is really there.

You may want to consider locking files &quot;IF&quot; there is a chance that some other part of you app will be reading that file (while you are deleting it)

FileExists()
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top