D盘已经有个文件夹“d:\abc”,里面已有多个文件,现在想复制到“c:\123”文件夹下。代码如下 :
- (defun c:ccdd (/ FSO)
- ;;; 复制文件,参考资料https://codeantenna.com/a/vfVkZPl6WT
- (vl-load-com)
- (setq FSO (vlax-create-object "scripting.FileSystemObject"))
- ;;; (vlax-dump-object FSO t)
- (setq sourcePath "d:\\abc"
- destinationPath "c:\\123"
- )
- ;;; (princ (vlax-invoke-method FSO 'FolderExists destinationPath))
- (if (= :vlax-false (vlax-invoke-method FSO 'FolderExists destinationPath))
- (vlax-invoke-method FSO 'CreateFolder destinationPath)
- (progn
- ;;; (alert "文件夹已存在。")
- )
- )
- (setq sourcePath (vlax-invoke FSO 'BuildPath sourcePath "\\*.*"))
- ;;; (alert sourcePath)
- (princ (vlax-invoke-method
- FSO 'CopyFile sourcePath destinationPath T))
- (vlax-release-object FSO) ;释放对象(结束进程)
- )
现在的问题是只运行成功一次,再次运行就出错。也就是不能实现覆盖。除非删除c:\123文件夹。求大神解答谢谢。
|