Try to Open .shp

Feb 26, 2013 at 6:30 PM
Hi, i have problem with open .shp file
Shapefile shp = new Shapefile();
            string filename = "states_ugl.shp";
            if (!shp.Open(filename, null))
                Console.WriteLine(shp.ErrorMsg[shp.LastErrorCode]);
            double[,] shapes = new double[shp.NumShapes, 3];
            shp.Close();
ErrorMsg just showing "No error", but shp is empty. please help me!
Feb 27, 2013 at 1:51 AM
From

string filename = "states_ugl.shp";

Change to

string filename = "C:...\states_ugl.shp";

Hope my answer will help you.
Jacky

Ps. I'm newbie in mapwingis and not good in English Language.
Feb 27, 2013 at 4:19 AM
Jacky, thank you for your answer. But it still haven't been working. Which version of Visual Studio are you using?
Feb 27, 2013 at 7:05 AM
vb 2010 + MapWinGIS v.4.8(lastest version)

sample code

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim shp As New MapWinGIS.Shapefile

    shp.Open("C:\map\Beach.shp")
    mapMain.AddLayer(shp, True)

End Sub

Feb 27, 2013 at 8:07 AM
Jacky, thank you for your answer. But it still haven't been working. Which version of Visual Studio are you using?
Feb 27, 2013 at 9:00 AM
Can you show your code ?
Feb 27, 2013 at 11:24 AM
Jacky, thank you for your answer. But it still haven't been working. Which version of Visual Studio are you using?
Feb 27, 2013 at 11:25 AM
Edited Feb 27, 2013 at 11:25 AM
Sorry for repost, my mistake(
namespace shptomif
{
    class Program
    {
        static void Main(string[] args)
        {
            
            Shapefile shp = new Shapefile();
            if (!shp.Open(@"..\..\Data\Austinstreets.shp", null))
                Console.WriteLine(shp.ErrorMsg[shp.LastErrorCode]);
            Console.ReadKey();
        }
    }
}
Feb 27, 2013 at 11:28 AM
Edited Feb 27, 2013 at 11:29 AM
This is a new code and it's work. Do you know something about converting .shp into .MIF/.MID file?
Coordinator
Mar 4, 2013 at 2:37 PM
First it is best the use sf as variable name for the shapefile and shp for the shape that is in the shapefile.

And you can use Utils.Ogr2Ogr() to convert a shapefile to mif.

Paul
Feb 6, 2015 at 1:28 PM
excusme. i want to add more layer(shp), but i don't know the source code to make it. please,help me