AnsweredAssumed Answered

Problem renaming directory via add-in

Question asked by Jim Sculley on Jun 7, 2010

I have a C# add-in that is doing some renaming and moving of files and directories.  Today I discovered that a rename operation on a directory is failing with a FileLoadException.


The exception message is;


"The process cannot access the file because it is being used by another process."  The FileName property for the exception is 'null'.


The problem only occurs if AutoCAD Electrical has opened (and subsequently closed) one of the files in the directory.  The obvious explanation would be that AutoCAD is holding something open.  However, if I duplicate the operations outside the vault, I can rename the directory with no problems.


So, the next logical source of the problem is my add-in code.  If I duplicate the actions of my add-in manually *inside* the vault, i get a slightly different error:


"One item could not be moved on the local disk"


The renamed directory appears in the vault, but the old directory that was supposed to be renamed is still there, as a local file (although it is now empty).


If I wrap my call to Rename with a try...catch block to catch the FileLoadException and ignore the exception itself, the same thing happens.  The folder is renamed, but a directory with the  'old' name is still there as a local file.


There were a couple of SPRs for EPDM 2008 associated with Rename from a dispatch add-in, but there was supposedly a hot-fix, and anyway I'm not using Dispatch.


Any insights?  Ignoring the Exception really rubs me the wrong way.


Jim S.