private void SaveShapeFile() { SaveFileDialog SFDlg = new SaveFileDialog(); SFDlg.Filter = "Shape File (*.shp)|*.shp"; if (SFDlg.ShowDialog() == DialogResult.OK) { //ProgressBar toolStripProgressBar1.Visible = true; this.Cursor = Cursors.WaitCursor; string aFile = SFDlg.FileName; //Create a VectorLayer with selected shapes int i, j; VectorLayer aLayer = new VectorLayer(_currentLayer.ShapeType); for (i = 0; i < _currentLayer.NumFields; i++) { aLayer.EditAddField(_currentLayer.Fields[i].ColumnName, _currentLayer.Fields[i].DataType); } bool hasSelShape = _currentLayer.HasSelectedShapes(); for (i = 0; i < _currentLayer.ShapeNum; i++) { Shape aPS = _currentLayer.ShapeList[i]; if (hasSelShape) { if (!aPS.Selected) { continue; } } int sNum = aLayer.ShapeNum; if (aLayer.EditInsertShape(aPS, sNum)) { for (j = 0; j < aLayer.NumFields; j++) { aLayer.EditCellValue(j, sNum, _currentLayer.GetCellValue(j, i)); } } Application.DoEvents(); this.toolStripProgressBar1.Value = (i + 1) * 100 / _currentLayer.ShapeNum; } aLayer.ProjInfo = _currentLayer.ProjInfo; aLayer.SaveFile(aFile); //Progressbar this.toolStripProgressBar1.Value = 0; this.toolStripProgressBar1.Visible = false; this.Cursor = Cursors.Default; } }