private void MergeFolderBtn_Click(object sender, EventArgs e) { string sourceDerectiony = FolderNameCom.Text.Trim(); TargetFile = FileNameCom.Text.Trim(); if (sourceDerectiony.Length <= 0 || TargetFile.Length <= 0) { MessageBox.Show("SourceFolder or TargetFile is null.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } else if (!Directory.Exists(sourceDerectiony)) { MessageBox.Show("SourceFolder isn't exist.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } if (File.Exists(TargetFile)) { File.Delete(TargetFile); } files = Directory.GetFiles(sourceDerectiony, "*.shp"); if (files.Length <= 1) { MessageBox.Show("Merge file less 1.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } ts1 = new TimeSpan(DateTime.Now.Ticks); //获取当前时间的刻度数 Progress = 0; backgroundWorker1.RunWorkerAsync(); int folderCount = 3; int filesCount = 3; //判断xml文件是否存在 if (!File.Exists(xmlName)) { ReadAndWriteXml.CreateXmlFile(xmlName, folderCount, filesCount); } //保存合并源文件夹和目标文件名称 ReadAndWriteXml.WriteFolderOrFileToXml(xmlName, sourceDerectiony, 1); ReadAndWriteXml.WriteFolderOrFileToXml(xmlName, TargetFile, 2); }
private void MergeShpFile_Load(object sender, EventArgs e) { if (File.Exists(xmlName)) { Collection <string> names = ReadAndWriteXml.LoadFileOrFolderName(xmlName, 1); foreach (string str in names) { FolderNameCom.Items.Add(str); } if (FolderNameCom.Items.Count > 0) { FolderNameCom.SelectedIndex = 0; } names = ReadAndWriteXml.LoadFileOrFolderName(xmlName, 2); foreach (string str in names) { FileNameCom.Items.Add(str); } if (FileNameCom.Items.Count > 0) { FileNameCom.SelectedIndex = 0; } } }