/// <summary> /// Initializes a new instance of the Shapefile class with the given parameters. /// </summary> /// <param name="filename">The filename of the shape file to read (with .shp).</param> /// <param name="geometryFactory">The GeometryFactory to use when creating Geometry objects.</param> public ShapefileReader(string filename, IGeometryFactory geometryFactory) { Guard.IsNotNull(filename, "filename"); Guard.IsNotNull(geometryFactory, "geometryFactory"); _filename = filename; _geometryFactory = geometryFactory; using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication()) { // read header information. note, we open the file, read the header information and then // close the file. This means the file is not opened again until GetEnumerator() is requested. // For each call to GetEnumerator() a new BinaryReader is created. using ( var stream = new IsolatedStorageFileStream(filename, FileMode.Open, FileAccess.Read, FileShare.Read, isf)) { using (var shpBinaryReader = new BigEndianBinaryReader(stream)) { _mainHeader = new ShapefileHeader(shpBinaryReader); shpBinaryReader.Close(); } } } }
/// <summary> /// Initializes a new instance of the Shapefile class with the given parameters. /// </summary> /// <param name="filename">The filename of the shape file to read (with .shp).</param> /// <param name="geometryFactory">The GeometryFactory to use when creating Geometry objects.</param> public ShapefileReader(string filename, IGeometryFactory geometryFactory) { Guard.IsNotNull(filename, "filename"); Guard.IsNotNull(geometryFactory, "geometryFactory"); _filename = filename; _geometryFactory = geometryFactory; using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication()) { // read header information. note, we open the file, read the header information and then // close the file. This means the file is not opened again until GetEnumerator() is requested. // For each call to GetEnumerator() a new BinaryReader is created. using ( var stream = new IsolatedStorageFileStream(filename, FileMode.Open, FileAccess.Read, FileShare.Read, isf)) { using (var shpBinaryReader = new BigEndianBinaryReader(stream)) { _mainHeader = new ShapefileHeader(shpBinaryReader); shpBinaryReader.Close(); } } } }
/// <summary> /// Initializes a new instance of the Shapefile class with the given parameters. /// </summary> /// <param name="filename">The filename of the shape file to read (with .shp).</param> /// <param name="geometryFactory">The GeometryFactory to use when creating Geometry objects.</param> public ShapefileReader(string filename, IGeometryFactory geometryFactory) { if (filename == null) throw new ArgumentNullException("filename"); if (geometryFactory == null) throw new ArgumentNullException("geometryFactory"); _filename = filename; _geometryFactory = geometryFactory; // read header information. note, we open the file, read the header information and then // close the file. This means the file is not opened again until GetEnumerator() is requested. // For each call to GetEnumerator() a new BinaryReader is created. var stream = IoManager.File.CreateFileStream(filename, FileMode.Open, FileAccess.Read, FileShare.Read); var shpBinaryReader = new BigEndianBinaryReader(stream); _mainHeader = new ShapefileHeader(shpBinaryReader); shpBinaryReader.Close(); }
/// <summary> /// Initializes a new instance of the Shapefile class with the given parameters. /// </summary> /// <param name="filename">The filename of the shape file to read (with .shp).</param> /// <param name="geometryFactory">The GeometryFactory to use when creating Geometry objects.</param> public ShapefileReader(string filename, IGeometryFactory geometryFactory) { if (filename == null) { throw new ArgumentNullException("filename"); } if (geometryFactory == null) { throw new ArgumentNullException("geometryFactory"); } _filename = filename; _geometryFactory = geometryFactory; // read header information. note, we open the file, read the header information and then // close the file. This means the file is not opened again until GetEnumerator() is requested. // For each call to GetEnumerator() a new BinaryReader is created. var stream = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.Read); var shpBinaryReader = new BigEndianBinaryReader(stream); _mainHeader = new ShapefileHeader(shpBinaryReader); shpBinaryReader.Close(); }