System.IO.FileNotFoundException

Topics: General Topics
May 26, 2013 at 4:57 AM
Edited May 26, 2013 at 5:01 AM
Hi,

I'm a beginner at .NET framework and need some help regarding an exception I'm getting when running Example 1 (compilation is fine):

A first chance exception of type 'System.IO.FileNotFoundException' occurred in SharpMap.dll
An unhandled exception of type 'System.IO.FileNotFoundException' occurred in SharpMap.dll
Additional information: The specified path does not lead to a file
The program '[3396] SharpMap_Forms.vshost.exe: Managed (v4.0.30319)' has exited with code 0 (0x0)

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
        SharpMap.Layers.VectorLayer vlay = new SharpMap.Layers.VectorLayer("States");
        vlay.DataSource = new SharpMap.Data.Providers.ShapeFile("path_to_data\\states_ugl.shp", true); <---
        mapBox1.Map.Layers.Add(vlay);
Before this I was getting an exception of type 'System.TypeInitializationException' in SHarpMap.UI.dll but I resolved it by looking at this thread: https://sharpmap.codeplex.com/discussions/444492

I'm using VS Express 2012 and have made sure I'm using the full .NET 4.0 version.
Any help would be much appreciated.
Thanks.
Coordinator
May 27, 2013 at 6:08 AM
vlay.DataSource = new SharpMap.Data.Providers.ShapeFile("path_to_data\\states_ugl.shp", true);
You probably need to change path_to_data\\states_ugl.shp to some real value. Leaving it as is, you need to have the whole shapefile set (shp, shx, dbf) in the folder path_to_data relative to your compiled exe.

Hth FObermaier