View Full Version : Changing file attributes with lisp
Is there a way I can change the attribute of a file to read-only with lisp?
Ed Jobe
2004-06-10, 05:39 PM
Its built into vba, but with lisp, you can use DOSlib from www.mcneel.com. Use the dos_attrib command.
stig.madsen
2004-06-10, 06:08 PM
... or write your own,
(defun SetRO (/ afile fso ofile ro)
(cond
((and (setq aFile (getfiled "" "" "" 4))
(setq fso (vlax-create-object "Scripting.FilesystemObject"))
(setq oFile (vlax-invoke fso 'GetFile aFile))
)
(vlax-put-property oFile 'Attributes (setq ro (- 1 (logand 1 (vlax-get-property oFile 'Attributes)))))
(princ (strcat "File set to " (nth ro '("Read-write" "Read-only"))))
(vlax-release-object oFile)
(vlax-release-object fso)
)
)
(princ)
)
Thanks everyone, Stig had what I was looking for.
stig.madsen
2004-06-11, 01:44 PM
Don't forget Robert McNeel has what you are looking for. I just thought it'd be more fun to write one.
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.