Obtain file creation date

bamver
bamver Member Posts: 30
Hi!

Does anybody know how can I get the creation date of a file? I know that is possible to know the last written date and time, but I want the creation date.

Thanks!

Comments

  • kine
    kine Member Posts: 12,562
    You can try to use "'Microsoft Scripting Runtime'.File" automation and the property DateCreated.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • bamver
    bamver Member Posts: 30
    Thanks, Kine!! It's exactly what I was looking for. But I don't know how to use those variables. I mean, which is exactly the code to open a textfile? I suppose It's necessary to use another "'Microsoft Scriptime Runtime'.FileSystemObject" variable, but I don't know how.

    Thank you very much in advance.
  • kine
    kine Member Posts: 12,562
    Something like this:
      FileAut := FyleSystemObject.GetFile(FileName);
      MESSAGE('%1',FileAut.DateCreated);
    

    But when I tried, I had problem that it could not find any file with path. It took only file name (without path part) and was searching for this file in Client folder.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Soft_Tod
    Soft_Tod Member Posts: 43
    Hi BamVer.

    You got to get the folder object before you can get the file object as Kine wrote.

    Best Regards
    It is impossible to make anything foolproof, because fools are so ingenious.
  • bamver
    bamver Member Posts: 30
    Got it!!

    The code I use:

    CREATE(FileSystemObject);
    File := FileSystemObject.GetFile(CurrDataport.FILENAME);
    MESSAGE(FORMAT(File.DateCreated));

    Thank you very much, Kine and Soft Tod!