This project is read-only.

Can't create row in shapefile's DBF

Jul 17, 2011 at 12:54 AM

I have a pretty strange issue.  I am simply trying to add a shape and DBF record to a shapefile.  I've been using this code for years.  Recently, I built an installer for it and saved the exe in program files and the data to the all users program data folder.  On XP, it works fine.  On Win7 it creates the shape but no record in the DBF file!?!?  Unless I run the exe as admin (which isn't good practice).  The strange thing is: it works fine as non-admin if I run it from my documents instead of the program files folder!?!?!

I created a sample program to isolate the problem.  I use the following code, build an exe and run it from my docs and it creates a new record, but if I run the exe from C:\program files\foldername it doesnt (unless I run as admin).  Any idea why, or how to fix this?

Also, using similar code I am able to edit an existing DBF record with no trouble as non-admin.


        Dim SF As New MapWinGIS.Shapefile, pt As MapWinGIS.Point, shp As MapWinGIS.Shape



        'Create a new Point and give it x and y values
        pt = New MapWinGIS.Point

        pt.x = CDbl(-84)
        pt.y = CDbl(38)

        'Create a new shape and add the point to it. If you had a line shape or polygon shape
        'then you would add several points to one shape.
        shp = New MapWinGIS.Shape
        shp.InsertPoint(pt, 0)

        SF.EditInsertShape(shp, 0)

        SF.EditCellValue(0, 0, 1)
        SF.StopEditingShapes(True, True) 'tried icall, but no errors

May 9, 2012 at 10:22 PM

Hi there,

I just came upon your post after finding myself with the same problem.


Did you find a solution yet?

Thanks! Koen

May 10, 2012 at 2:45 AM

Turns out my problem was I was trying to write to the "program files" folder (win7) and I did not have the rights to do so.  I moved the shapefile to the appdata folder and all is fine.


Hope that helps.  :)

May 10, 2012 at 8:36 AM

Thanks for the prompt reply, but your solution did not work for me...

I changed the location to the CurrentUserApplicationData-dir, noticed that my program stores the shapefile in de specified location, but again: no records in the dbf-file. After changing the user-settings from User to Admin, everything worked fine.

I even tried storing in the MyDocs-dir, but with similar problems.


Any other suggestion?

Thanks, Koen

May 10, 2012 at 12:54 PM

I think the other thing I had to do was to run his script with my installer:

Dim Act : Set Act = CreateObject("Wscript.Shell")
DIM fso : Set fso = CreateObject("Scripting.FileSystemObject")

If (fso.FileExists("C:\windows\system32\icacls.exe")) Then
Act.Run("icacls ""%APPDATA%\signprox"" /reset /t"),1,True
Act.Run("icacls ""%APPDATA%\signprox"" /grant Users:(OI)(CI)M"),1,True
Act.Run("icacls ""%PROGRAMFILES%\signprox"" /reset /t"),1,True
Act.Run("icacls ""%PROGRAMFILES%\signprox"" /grant Users:(OI)(CI)M"),1,True
End If

May 10, 2012 at 5:19 PM

Again no luck for me...

I tried to grant user permissions to the folders in my installer and by hand, but this does not seem to work.

Changing the account to admin bypasses the problem, but this is not an option.


May 10, 2012 at 9:58 PM

That is odd.  I had the exact same behavior and this worked fine.  What is your program?

May 11, 2012 at 6:05 AM
I had something to do with other parts of my code. I still don't understand why, but it failed when building and filling shapefiles from an in-memory dataset. I built two options: 1. from dataset, 2. from XML. These were the exact pieces of code for the filling of the data (other than a different approach to collect the data). Somehow building from xml worked fine, so I extended this a bit and totally skipped building from dataset.

Not solved, but for me a decent workaround.
Thanks anyway for thinking with me.

2012/5/10 irkgreen <>

From: irkgreen

That is odd. I had the exact same behavior and this worked fine. What is your program?

Read the full discussion online.

To add a post to this discussion, reply to this email (

To start a new discussion for this project, email

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at

K.P. Volleberg
Oude Arnhemseweg 27
3702 BA - Zeist (NL)