Author Topic: vl-file-systime does not work on open file  (Read 3659 times)

0 Members and 1 Guest are viewing this topic.

ahankhah

  • Guest
vl-file-systime does not work on open file
« on: November 05, 2014, 01:55:17 AM »
    Hi all,

    Although vl-file-systime works fine on most files (even readonly ones), it doesn't work on open files.

    Could any one introduces alternatives to vl-file-systime function to get the time of such files?

    I appreciate any help and clues to solve the problem

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: vl-file-systime does not work on open file
« Reply #1 on: November 05, 2014, 02:33:30 AM »
You could use the ActiveX file system object:
Code - Auto/Visual Lisp: [Select]
  1. (defun file-property (path prop / fso f p)
  2.   (vl-catch-all-apply '(lambda ()
  3.                          (setq fso (vlax-get-or-create-object "Scripting.FileSystemObject")
  4.                                f   (vlax-invoke fso "GetFile" path)
  5.                                p   (vlax-get f prop))))
  6.   (vl-catch-all-apply 'vlax-release-object (list f))
  7.   (vl-catch-all-apply 'vlax-release-object (list fso))
  8.   p)
  9.  
  10. (defun file-DateCreated (path) (file-property path "DateCreated"))
  11. (defun file-DateLastAccessed (path) (file-property path "DateLastAccessed"))
  12. (defun file-DateLastModified (path) (file-property path "DateLastModified"))

Note it returns some "weird" date/time real instead of the y/m/d/etc. or even a proper standard date/time real. To convert it so it's actually useful look here: http://forums.augi.com/showthread.php?120360-Find-creation-date-of-folder
« Last Edit: November 05, 2014, 05:36:12 AM by irneb »
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: vl-file-systime does not work on open file
« Reply #2 on: November 05, 2014, 04:06:57 AM »
Please search the forum before posting a new thread  :-)

http://www.theswamp.org/index.php?topic=43559.msg488184#msg488184

ahankhah

  • Guest
Re: vl-file-systime does not work on open file
« Reply #3 on: November 05, 2014, 05:09:14 AM »
Irneb, thank you very much.

Lee, thank you too. You are right. Of course I searched internet by google with no success to find any reply.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: vl-file-systime does not work on open file
« Reply #4 on: November 05, 2014, 08:35:02 AM »
Use google advanced search  http://www.google.com/advanced_search?hl=en
and paste this in the site or domain:  http://www.theswamp.org/index.php?board=2.0 to search the Swamp Lisp board
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: vl-file-systime does not work on open file
« Reply #5 on: November 05, 2014, 08:45:24 AM »
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

ahankhah

  • Guest
Re: vl-file-systime does not work on open file
« Reply #6 on: November 05, 2014, 10:47:30 AM »
Use google advanced search  http://www.google.com/advanced_search?hl=en
and paste this in the site or domain:  http://www.theswamp.org/index.php?board=2.0 to search the Swamp Lisp board

lmgtfy ...

CAB, MP, thank you. I appreciate your help.