public void initializationFolderAndFile() { // Read the folder name and file name to regedit. RegeditReadAndWrite regeditReadAndWrite = new RegeditReadAndWrite(10); Collection <string> Folder = regeditReadAndWrite.ReadRegedit("Folder"); Collection <string> File = regeditReadAndWrite.ReadRegedit("File"); cbxFolder.Items.Clear(); cbxFile.Items.Clear(); if (Folder != null) { foreach (string item in Folder) { cbxFolder.Items.Add(item); } cbxFolder.SelectedIndex = 0; } if (File != null) { foreach (string item in File) { cbxFile.Items.Add(item); } cbxFile.SelectedIndex = 0; } }
private void ButtonMergeTwo_Click(object sender, EventArgs e) { string sourceDerectiony = cbxFolder.Text.Trim(); TargetFile = cbxFile.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; } files = Directory.GetFiles(sourceDerectiony, "*.shp"); if (files.Length <= 1) { MessageBox.Show("Merge file less 1.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } Progress = 0; backgroundWorker1.RunWorkerAsync(); this.lblPercent.Text = ""; this.lblPercent.Visible = true; btnCancel.Enabled = true; ts1 = new TimeSpan(DateTime.Now.Ticks); //获取当前时间的刻度数 // Write the folder name and file name to regedit. RegeditReadAndWrite regeditReadAndWrite = new RegeditReadAndWrite(10); regeditReadAndWrite.WriteRegedit("Folder", sourceDerectiony); regeditReadAndWrite.WriteRegedit("File", TargetFile); // Initialization the folder droplist and file droplist. initializationFolderAndFile(); }