Spec-Zone.ru › ColdFusion

fileDelete

Deletes the specified file on the server. fileDelete throws an exception whenever a file doesn't exist.

fileDelete(filePath) → returns void

  • CF8+
  • Lucee
  • BL 1.0.0+
  • See Also: fileWrite directoryDelete

    Argument Reference

    filePath string
    Required

    Pathname of the file to delete. If not an absolute path (starting with a drive letter and a colon, or a forward or backward slash), it is relative to the ColdFusion temporary directory, which is returned by the GetTempDirectory function.

    Examples
    Sample code invoking the fileDelete function

    Script Syntax

    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.

    © 2012–present Foundeo, Inc. and the CFDocs contributors.
    Licensed under the MIT License.
    ColdFusion is a trademark of Adobe Systems Incorporated.
    https://cfdocs.org/filedelete

    Spec-Zone.ru

    Настройки Оффлайн Что нового Помощь О нас
    Spec-Zone .ru
    спецификации, руководства, описания, API