I am trying to export an empty shapefile so that I can then add a WKT feature to it for viewing. Please assume the WKT string is correct as it passes validation. When trying to create the file I receive the following error:
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Dim feature As New Feature(TextBox1.Text)
Dim s As New DbfColumn("filler", DbfColumnType.String, 1, 1)
Dim colms As New System.Collections.ObjectModel.Collection(Of DbfColumn)
colms.Add(s)
ShapeFileFeatureLayer.CreateShapeFile(ShapeFileType.Polygon, "C:\zzz\WKT.shp", colms, System.Text.Encoding.Default, OverwriteMode.Overwrite)
Dim fL As New ShapeFileFeatureLayer("C:\zzz\WKT.shp", ShapeFileReadWriteMode.ReadWrite)
fL.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.FromArgb(180, 230, 0, 0), GeoColor.SimpleColors.Black)
fL.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20
ShapeFileFeatureLayer.BuildIndexFile("C:\zzz\empty.shp")
WinformsMap1.MapUnit = GeographyUnit.Meter
fL.Open()
fL.EditTools.BeginTransaction()
fL.FeatureSource.AddFeature(feature)
fL.EditTools.CommitTransaction()
Dim extent As RectangleShape = fL.GetBoundingBox
fL.Close()
WinformsMap1.CurrentExtent = extent
WinformsMap1.StaticOverlay.Layers.Add("emerald", fL)
WinformsMap1.Refresh()
End Sub
When trying to do this I receive the following error:
The process cannot access the file 'C:\zzz\TMPWKT.dbf' because it is being used by another process.
What am I doing wrong?