Deletes the specified file on the server.
Throws an exception if the file doesn't exist.
FileDelete(file=[string])
file
string
true
The file to delete.
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() ) > 1 ) {
fileDelete( file.DIRECTORY & "\" & file.NAME );
}
}
Result: All files within the archive directory older than one hour will be deleted.
fileDelete( "my/path/to/file.md" );