Deletes the specified file on the server. fileDelete throws an exception whenever a file doesn't exist.
fileDelete(filePath)
→ returns void
Obtaining files within an archive folder and then removing them if they are older than one hour.
var existingFiles = directoryList(expandPath("/archive/"), false, "query");
for (file in existingFiles) {
if (dateDiff("h", file.datelastmodified, now()) GT 1) {
fileDelete(file.directory & "\" & file.name);
}
}
Expected Result: All files within the archive directory older than one hour will be deleted.
Signup for cfbreak
to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.