vl-file-delete with 2018 version

vl-file-delete with 2018 version

hannu.kiiskinen
Participant Participant
1,327 Views
4 Replies
Message 1 of 5

vl-file-delete with 2018 version

hannu.kiiskinen
Participant
Participant

Hi,

 

Has anyone noticed that vl-file-delete is not working with version 2018 of AutoCAD Mechanical. It executes the command without errors but files are not deleted. The same program was working fine in previous AutoCAD Mechanical version. Just wishing to get Serveice Pack soon which fixes also this bug.

 

Br, Hannu

0 Likes
Accepted solutions (1)
1,328 Views
4 Replies
Replies (4)
Message 2 of 5

ActivistInvestor
Mentor
Mentor

@hannu.kiiskinen wrote:

Hi,

 

Has anyone noticed that vl-file-delete is not working with version 2018 of AutoCAD Mechanical. It executes the command without errors but files are not deleted. The same program was working fine in previous AutoCAD Mechanical version. Just wishing to get Serveice Pack soon which fixes also this bug.

 

Br, Hannu


Strange.

 

You can use this as a temporary workaround.

 

(defun file-delete (path / fso)
    (setq fso (vlax-create-object "Scripting.FileSystemObject"))
    (vlax-invoke-method fso 'DeleteFile path :vlax-false)
    (vlax-release-object fso)
)

;; To allow the use of the above in existing LISP that
;; calls vl-file-delete:

(setq vl-file-delete file-delete)

0 Likes
Message 3 of 5

dgorsman
Consultant
Consultant

What file are you trying to delete?  And what was your previous version?

----------------------------------
If you are going to fly by the seat of your pants, expect friction burns.
"I don't know" is the beginning of knowledge, not the end.


0 Likes
Message 4 of 5

cadffm
Consultant
Consultant

Tested with Mechanical2018.1.1

vl-file-delete works well, show us your code!

 

Perhaps you dont use only the filename without the fullpath information and you Supportpathes are different to previous installs/profiles?

Everytime when you want to delete Files, you should use fullpath+name+ext (D:\\mypath\\myfile.docx)

 

; simple example without to check rights and write-rights
(progn (setq f (getfiled "" "" "" 0)) (alert (if (findfile f) "Start" (strcat f " - could not find"))) (alert (strcat f (if (vl-file-delete f) " - deleted" " - could not deleted"))) (alert (strcat f (if (findfile f) " - exists" " - is deleted!"))) )

 

Sebastian

0 Likes
Message 5 of 5

hannu.kiiskinen
Participant
Participant
Accepted solution

H again,

 

I solved the problem. Thanks for the info that vl-file-delete is working fine. The file was open for read in lisp and no permission to delete because of that (not my own code so didn't notice this immediately). Adding close of the file and vl-file-delete start working as expected.

 

Br, Hannu

0 Likes