[Shapelib] SHPOpen (and SHPCreate) only recognizes the first letter of filename

Tom Kazimiers 2voodoo at gmx.de
Wed Jul 18 04:04:23 PDT 2007


Hi there,

after struggleing some days around with getting Shapelib compiled for
Pocket PC 2003 and Windows CE I finally succeeded with this and came up
to the .Net wrapper I found on the net which is quite helpfull as I do
not need to care about all the P/Invoke stuff out of C#.
This worked after some work, too but for my last problem I did not find
any solution.

If I want to open or create a file with SHPOpen and SHPCreate only the
first letter of the given filename is recognized. Furthermore if I have
a filepair "t.shx" and "t.shp" and want to open "test" - then t is opened.

First of all I had to change something in the wrapper - namely the
charset as Ascii (which was written there) was not found on my computer
so I set it to auto:

[DllImport("Shapelib.dll", CharSet = CharSet.Auto)]
public static extern IntPtr SHPOpen(string szShapeFile, string szAccess);

Could this already be a problem?

Now I want to open a file:

IntPtr hShp = ShapeLib.SHPOpen("test", "rb");

which succeeds if there is a file "t.shx" and "t.shp", but not if there
are the files "test.shx" and "test.shp".
With the t-files I can read everything and work with them, but I want
full filenames. The problem gets even worser if I want to use
directories. (all the files mentioned above where saved in "root") as
SHPOpen can't handle this. The same is true for creation of shapefile-pairs.

I could image that there is a charset problem as I changed this in the
MapTools.cs, but I don't know how to solve this.

Do you have any ideas or hints?

Thank you in advance.
Tom





More information about the Shapelib mailing list