Author Topic: Cannot delete file. Getting "file is open in AutoCAD" error.  (Read 1574 times)

0 Members and 1 Guest are viewing this topic.

Rabbit

  • Guest
Cannot delete file. Getting "file is open in AutoCAD" error.
« on: October 06, 2015, 09:47:51 AM »
I'm sure someone has run into something like this before.  Google has not been my friend either.  I used (setq SetFile (open TextFile "W")) to open a file.  While the file was open for writing, I hit ESC.  (setq SetFile (close SetFile)) never got issued and the variable SetFile was set to NIL.  Now, (setq SetFile (open TextFile "W")) will only return NIL and since SetFile was set to NIL, (setq SetFile (close SetFile)) gives a "bad argument type: streamp nil" error.  This was in a testing phase and I hadn't gotten an ERROR trap set up.  So, the file was left open by AutoCAD and I cannot move, rename nor delete it.  I know that (open TextFile "W") gets the {name} "c:myfile" {mode} :OUTPUT {id} <random number> and {position} 0 .  Is there a way to set the mode to :CLOSE ?  Will that even work?  When I do a (setq SetFile (open TextFile "R")) on the file, it gives the same info as above, but also the field {EOF} nil .


Also, I have tried closing and rebooting.  I have also tried using the CMD method and fileunlocker won't work for a file on the server.
Thanks to everyone that takes the time to look at this.

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Cannot delete file. Getting "file is open in AutoCAD" error.
« Reply #1 on: October 06, 2015, 09:58:32 AM »
Usually closing AutoCAD will release the file descriptor, allowing you to modify the file.

Aside, note that the expression (setq SetFile (close SetFile)) can be (close SetFile) to perform the same operation. I use (setq <file-descriptor> (close <file-descriptor>)) in my code as the close function will always return nil and I use a conditional to test for the file descriptor variable in the *error* function.

Rabbit

  • Guest
Re: Cannot delete file. Getting "file is open in AutoCAD" error.
« Reply #2 on: October 06, 2015, 10:10:03 AM »
*BANG HEAD AGAINST DESK*
*BANG HEAD AGAINST DESK*
*BANG HEAD AGAINST DESK*
*BANG HEAD AGAINST DESK*
*BANG HEAD AGAINST DESK*
*BANG HEAD AGAINST DESK*

The guy I was writing this file for had it opened on his computer when I was verifying the information was correct.  For 2 days it was left open.  I though I had done it in my testing.  Turned out, it wasn't my fault at all.  I went to him to tell him to not use the file because it had "issues".  His response "Oh, I just closed that a few minutes ago."

*BANG HEAD AGAINST DESK*
*BANG HEAD AGAINST DESK*
*BANG HEAD AGAINST DESK*
*BANG HEAD AGAINST DESK*
*BANG HEAD AGAINST DESK*
*BANG HEAD AGAINST DESK*
repeat indefinitely.........

Thanks for the help guys.  Sorry to waste your time too.
SMH

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Cannot delete file. Getting "file is open in AutoCAD" error.
« Reply #3 on: October 06, 2015, 12:21:09 PM »
 :-D