public static void Merge(string[] SourceFiles, string targetFile) { File.Copy(SourceFiles[0], targetFile, true); ShpFile outFile = new ShpFile(targetFile, ShapeFileOpenMode.FileReadFirst); for (int i = 1; i < SourceFiles.Length - 1; i++) { ShpFile mergeFile = new ShpFile(SourceFiles[i], ShapeFileOpenMode.FileRead); outFile.Merge(mergeFile); } outFile.Close(); }
public static void Merge(string[] SourceFiles, string targetFile, BackgroundWorker worker, DoWorkEventArgs e) { File.Copy(SourceFiles[0], targetFile, true); ShpFile outFile = new ShpFile(targetFile, ShapeFileOpenMode.FileReadFirst); for (int i = 1; i < SourceFiles.Length; i++) { ShpFile mergeFile = new ShpFile(SourceFiles[i], ShapeFileOpenMode.FileRead); outFile.Merge(mergeFile); mergeFile.Close(); int percentComplete = (int)((float)(i + 1) / (float)SourceFiles.Length * 100); worker.ReportProgress(percentComplete); if (worker.CancellationPending) { e.Cancel = true; outFile.Close(); return; } } outFile.Close(); }