How to find out when a file was created in ColdFusion

I found a function that returns file information: GetFileInfo ()

It returns the following data:

  • Name : file name
  • Path : absolute file path
  • Parent : path to the parent file directory
  • Enter : either "directory" or "file"
  • Size : file size in bytes
  • Lastmodified : datetime when it was last modified.
  • canRead : can the file be rea
  • canWrite : does the file have write permission
  • isHidden : whether the file is hidden

But this data is not displayed when the file was actually created. How to find out?

+5
source share
1 answer

(From the comments ...)

This was probably omitted because it is o / s level metadata. Assuming the creation date is supported on your o / s, try using java.nio :

<cfscript> physicalPath = "c:/path/to/someFile.ext"; // Get file attributes using NIO nioPath = createObject("java", "java.nio.file.Paths").get( physicalPath, [] ); nioAttributes = createObject("java", "java.nio.file.attribute.BasicFileAttributes"); nioFiles = createObject("java", "java.nio.file.Files"); fileAttr = nioFiles.readAttributes(nioPath, nioAttributes.getClass(), []); // Display NIO results as date objects writeOutput("<br> creation (date): "& parseDateTime(fileAttr.creationTime())); writeOutput("<br> modified (date): "& parseDateTime(fileAttr.lastModifiedTime())); // Display CF results for comparison fileInfo = getFileInfo(physicalPath); writeDump(fileInfo); </cfscript> 
+6
source

Source: https://habr.com/ru/post/1261376/


All Articles