Quanthema Quanthema -3 years ago 153
C# Question

How to add shape file at EGIS in c#?

I am using

EGIS
library and
SfMap
tool belongs to
EGIS
, but I cannot open or read shape file.

The name of the file that I try to open is
roads.shp
.

In
AddShapeFile
it says I should write:
(string path,string name,string labelFieldName)
. I write as in below but it gives an error such as"ArgumentException was unhandled". What should I do?

private void button1_Click(object sender, EventArgs e)
{
sfMap1.AddShapeFile(@"C:\Users\Quanthema\Desktop\Paylasim\Performance Test", "roads", "");
}

Answer Source

The API documentation for SFMap.AddShapeFile says this about the parameters:

path Type: System..String The file path to the ShapeFile
name Type: System..String The "display" name of the ShapeFile.
labelFieldName Type: System..String The name of the field in the ShapeFiles's DBF file to use when rendering the shape labels

Where you have:

sfMap1.AddShapeFile(@"C:\Users\Quanthema\Desktop\Paylasim\Performance Test", "roads", "");

It looks like you are not providing the full file path for the first path parameter, and you have the file name in the "display" name field.

Try something like this:

sfMap1.AddShapeFile(@"C:\Users\Quanthema\Desktop\Paylasim\Performance Test\roads.shp", "ShapeFile", "");

From the example usage here it looks like you can pass in an empty string as the third parameter, so I don't think that is the issue.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download