Reputation: 942
When this method is invoked I get the following stack trace when it reaches OpenAsync():
System.Exception: Shape file not found: C:\Users\Laura\Desktop\shapes\TOTALMAP\OH_Line_6600v_Expired.shp at RuntimeCoreNet.Interop.HandleException(Boolean retVal) at RuntimeCoreNet.CoreFeatureSource.FromShapefile(String filename) at Esri.ArcGISRuntime.Data.ShapefileTable.OpenAsync(String filename)
at ShapeSQLiteGISDemo.MainPage.d__3.MoveNext()
I have a .dbf and .shx file in the same folder with the same name and I've been running Visual Studio in Administrator Mode.
private async void ImportShapes(object sender, RoutedEventArgs e)
{
try
{
//Get path from file picker
var picker = new FileOpenPicker { SuggestedStartLocation = PickerLocationId.Desktop };
picker.FileTypeFilter.Clear();
picker.FileTypeFilter.Add(".shp");
var file = await picker.PickSingleFileAsync();
//convert folder contents to a ShapefileTable
var shapefile = await ShapefileTable.OpenAsync(file.Path);
//save object to database
_DatabaseConnection.Insert(shapefile);
}
catch (Exception ex)
{
Debug.WriteLine(ex);
}
//call a method that loads shapes from the database
LoadDatabaseOntoMap();
}
Any help much appreciated.
Upvotes: 1
Views: 292
Reputation: 7712
Try using an app like notepad to open the file by pasting in the path:
C:\Users\Laura\Desktop\shapes\TOTALMAP\OH_Line_6600v_Expired.shp
Does the app open the file?
Are there other examples of shape files that do open? Could this file simply be corrupted?
Upvotes: 0
Reputation: 942
I believe the problem is that with Store and UWP apps the .shp file has to be moved to a folder in the local storage before the application can open it.
Will set as the accepted answer if this solves the problem.
EDIT: This is indeed the case, because I was choosing a single file with the the file picker I only had access to that one file. To get multiple files I used the folder picker and filtered away any files that weren't useful.
Upvotes: 2