Select to view content in your preferred language

Shapefile LOCK files

8855
11
02-03-2011 06:52 AM
MatthewMalinowski
New Contributor
Hello,

I have a WCF service that opens a collection of shapefiles and uploads the data from these shapefiles into their respective SDE feature classes.  Everything works perfectly except at the very end when I wish to delete the shapefiles as they are stored in a temporary location on the server. The act of opening a featurecursor on the shapefiles creates a LOCK file the same as if you were to view the file in ArcCatalog.  I do everything that I can possibly think of to release the lock on the shapefile, including System.Runtime.Interop.Marshal.ReleaseComObject & FinalReleaseComObject (neither works) on all ArcObjects that I use along with shutting down the ArcObjects license that I check out at the beginning of the whole procedure. I cannot find any hints as to how to release the lock on the shapefile.  It eventually goes away if I wait long enough, but I need for it to go away immediately after I am done looping through the feature cursor.  Does anyone have any ideas on how to release these locks? I tried to use the ESRI.ArcGIS.esriSystem.IAppLockMgr but I cannot find any examples on how to use this and I'm not even sure if it is the correct interface to use for this.

Any help would be GREATLY appreciated.

Thanks in advance,

- Matt
0 Kudos
11 Replies
KirkKuykendall1
Frequent Contributor

Does your pGxObjects represent a collection of shapefiles in a folder?

If so, I'd try opening the folder as a workspace make a List<IName> from IWorkspace.DatasetNames, and avoid using stuff in the Esri.Arcgis.Catalog altogether.

If you must use IGxCatalog,  perhaps create a List<IName> from the pGxObjects, then call IGxCatalog.Close(), then loop through each name in the list.

I've always been suspicious of what IGxCatalog does behind the scenes - maybe for performance it's caching references(?)

DaveLewis73
Regular Contributor

Kirk, I think that may have worked (or at least well enough).  I tested on a single folder with 15 shapefiles and all but one of the lock files went away.  I don't know what that is all about, but I will have to try and figure that out later.  I am just happy that I have made some progress.  Now, I just have to go through my enormous application and make all of the necessary changes, which will not be fun.

Thank you.

0 Kudos