Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

To change values and add new values to a dbf-file, I connect to the dbf and use the ITable interface to make the edits. At the end I release the COM-objects of the table and the workspace. But when I try to open the changed file, it says the file is read-only. Did I forget to release something else? Or is there another reason for the read-only status?

Thanks and regards Fab

share|improve this question
1  
Could you add some code, it's easier to help solve a developer question when having some code to look at. –  MathiasWestin Nov 17 '10 at 21:46
add comment

2 Answers

As to my knowledge and personal experience, this is a general issue when opening files in ArcMap/ArcCatalog or by means of ArcObjects. The lock on those files doesn't get released when they are no longer used in the application. Only closing all ArcGIS applications solves that problem. That behavior is widely known and it's frustrating.

share|improve this answer
    
My experience also. –  Brad Nesom Dec 29 '10 at 20:29
add comment

In my case, I found that the dbf was not locked, but there were stray lock files associated with the dbf. While ArcCatalog was still running, I was able to delete the table, but I was not able to delete the folder containing the dbf. Deletion of the parent directory failed when using the ArcCatalog GUI or Windows Explorer. I was able to delete the folder using the Delete_management geoprocessing tool.

I had considered accessing the dbf using a non-ArcObjects method, but I realized I would probably run into this problem later with feature classes and geodatabases, so it was best to continue using ArcObjects.

To better manage this issue, I intend to create the table in the scratch workspace (system temp if unspecified) then move the file to the correct destination when I'm finished accessing it.

You might want to try this code:

System.Runtime.InteropServices.Marshal.ReleaseComObject(tableRows);

I found that it did remove one of the two lock files associated with the dbf. The first reference below has a long discussion on the ReleaseComObject method and recommends its use on geodatabase cursors.

References:

EDN: How to release COM references

gis.stackexchange: How do I remove schema locks from a file geodatabase in java?

Stackoverflow.com: How do you remove a schema lock on a dbf file accessed using arcobjects?

ASPCode.net: Reading DBF files in C#

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.