ThinkGeo.com    |     Documentation    |     Premium Support

Problem loading shape file

Hello All,


I'm very new to this setup, so please bear with me if this problem seems too simplistic.


I'm going through the initial tutorial for Web Edition 3.0, essentially just copying and pasting the code.  I have the reference to MapSuiteControl.DLL, and the Map control both in the project flawlessly.  The problem comes, however, when I try to load a basic shape file.  When using:


ShapeFileLayer layer = new ShapeFileLayer(MapPath(@"C:\Program Files\ThinkGeo\Map Suite Web Full Edition 3.0 (Beta)\Samples\CSharp Samples\SampleData\World\cntry02.shp"), ShapeFileReadWriteMode.ReadOnly);


I receive an 'Invalid Vitual Path' error in Visual Studio.


If I remove the 'MapPath' cast, I receive a 'File Does Not Exist' error on the web page.  The file, however, is indeed at the specified path, with no permission lock on it, or anything of that nature. 


I have noticed that when setting the ShapePathFileName in the manner above, the IndexPathFileName is also set to the same path, with a '.idx' extention.  That file does not exist and was not included with the Map Suite download, though. I don't know if this will effect the outcome of the situation.


Can anyone help me?  I'm certain the problem is glaringly obvious to some of you pros.  Thank you in advance. 



Dustin,


What you are declaring below is not a virtual path:

C:\Program Files\ThinkGeo\Map Suite Web Full Edition 3.0 (Beta)\Samples\CSharp Samples\SampleData\World\cntry02.shp


This is a virtual path taken from the DisplayASimpleMap sample application: ~/SampleData/world/cntry02.shp


Are you using the Full Edition or the Evaluation Edition of the Map control? If you are using the Evaluation Edition you should change your concrete path to: C:\Program Files\ThinkGeo\Map Suite Web Evaluation Edition 3.0 (Beta)\Samples\CSharp Samples\SampleData\World\cntry02.shp


So you have two options:


Use a concrete path:

ShapeFileLayer worldLayer = new ShapeFileLayer(@"C:\Program Files\ThinkGeo\Map Suite Web Evaluation Edition 3.0 (Beta)\Samples\CSharp Samples\SampleData\World\cntry02.shp", ShapeFileReadWriteMode.ReadOnly);



Use a virtual path: 

ShapeFileLayer worldLayer = new ShapeFileLayer(MapPath("~/SampleData/world/cntry02.shp"));



Ryan,


Thanks very much for the explaination.  The concrete path worked like a charm. Told you it was easy. ;-)  



Glad it is working for you!