You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

AutoLisp获取文件最后修改日期失败:解决报错及替代方案

问题:获取文件最后修改日期时出现参数缺失错误,求替代方案

我需要获取文件列表的最后修改日期以实现排序功能,已找到可更新文件修改日期的代码,但反向获取时使用vlax-get和vlax-get-property持续收到Error: Missing parameter for function.错误。

(vl-load-com)

;; Original code
(defun SetFileLastModified ( file date / i fso fObj sh 
    oFolder oFiles iCount fItem filepath
    vTemp) 
      
    (setq fso (vlax-create-object "Scripting.FileSystemObject"))
    (if (= (vlax-invoke fso 'FileExists file) :vlax-true)
        (progn ;; True
            (setq sh (vla-getinterfaceobject (vlax-get-acad-object) "Shell.Application"))
            (setq oFolder (vlax-invoke sh 'NameSpace (vl-filename-directory file)))
            (setq oFiles (vlax-invoke oFolder 'Items))
            (setq iCount (vlax-get oFiles 'Count))
            (setq i 0)
            (while (< i iCount)
                (setq fItem (vlax-invoke oFiles 'Item i))
                (setq filepath (vlax-get fItem 'path))
                (if (= (vl-filename-base filepath) (vl-filename-base file))(progn
                    (vlax-put fItem 'ModifyDate date);<-- Command to update the last modified date.
                ));if
                (setq i (1+ i))
            );while
            (vlax-release-object sh)
        );progn ; True
        (print (strcat "File not found: " file)); False
    );if
    (vlax-release-object fso)
);PullLastModified


;; Failed attempt
(defun PullLastModified ( file / i fso fObj sh 
    oFolder oFiles iCount fItem filepath
    vTemp) 
     
    (setq fso (vlax-create-object "Scripting.FileSystemObject"))
    (if (= (vlax-invoke fso 'FileExists file) :vlax-true)
        (progn ;; True
            (setq sh (vla-getinterfaceobject (vlax-get-acad-object) "Shell.Application"))
            (setq oFolder (vlax-invoke sh 'NameSpace (vl-filename-directory file)))
            (setq oFiles (vlax-invoke oFolder 'Items))
            (setq iCount (vlax-get oFiles 'Count))
            (setq i 0)
            (while (< i iCount)
                (setq fItem (vlax-invoke oFiles 'Item i))
                (setq filepath (vlax-get fItem 'path))
                (if (= (vl-filename-base filepath) (vl-filename-base file))(progn
                    (princ "\nTest-01\n")
                    (setq vTemp (vlax-get fItem 'ModifyDate));<-- Having trouble pulling the modified date.
                    (princ "\nModified Date : ")(prin1 vTemp)(terpri)
                ));if
                (setq i (1+ i))
            );while
            (vlax-release-object sh)
        );progn ; True
        (print (strcat "File not found: " file)); False
    )
    (vlax-release-object fso)
);PullLastModified

更新
已发现无法使用'DateLastModified获取最新修改日期的原因,求可行替代方案?

数据属性值

内容的提问来源于stack exchange,提问作者G Beck

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.06 03:30:42