这是我的情况,
我有一个 ESRI Map Silverlight 应用程序,它需要显示客户端提供给我的 ShapeFiles。
我发现的唯一允许您执行此操作的第三方库是ESRI Silverlight API Contrib。他们给出的示例是使用打开文件对话框来选择形状文件并将它们加载到 FileInfo 类中以显示。(参见网站首页上的示例)。
但是我遇到了一个问题,因为它是一个 Silverlight 应用程序,任何实例化 FileInfo 对象实例的尝试都会导致应用程序崩溃。
所以我的问题是,有没有办法让我加载/显示我在 Silverlight 中本地保存到应用程序的形状文件?
如果您需要我提供更多信息,请告诉我。
提前致谢!
代码:
FileInfo runwayShp = new FileInfo("Layers\\Runway.shp"); //This line breaks, says file access is denied.
FileInfo runwayDbf = new FileInfo("Layers\\Runway.dbf");
ShapeFile shapeFileReader = new ShapeFile();
if (runwayShp != null && runwayDbf != null)
{
shapeFileReader.Read(runwayShp, runwayDbf);
}
GraphicsLayer graphicsLayer = MyMap.Layers["ShapeLayer"] as GraphicsLayer;
foreach (ShapeFileRecord record in shapeFileReader.Records)
{
Graphic graphic = record.ToGraphic();
if (graphic != null)
graphicsLayer.Graphics.Add(graphic);
}
}