private void btnGroup_Click(object sender, EventArgs e) { FolderBrowserDialog Folder = new FolderBrowserDialog(); Folder.SelectedPath = this.lastPath; if (Folder.ShowDialog() == DialogResult.OK) { this.lastPath = Folder.SelectedPath; List <string> FILEs = ShiftFileNames(Directory.GetFiles(lastPath).ToList()); if (FILEs.Count > 0) { TransCoordinateSystem TCS = new TransCoordinateSystem(); foreach (string file in FILEs) { string SaveFileName = Path.GetFileNameWithoutExtension(file) + "_圖號座標轉換.xlsx"; TCS.Main_start(file, lastPath, SaveFileName); } MessageBox.Show("檔案處理完成!"); this.Saveing(); return; } MessageBox.Show("無excel檔案!"); } ; }
private void btnSingle_Click(object sender, EventArgs e) { OpenFileDialog dialog = new OpenFileDialog(); dialog.Title = "選擇excel檔案"; dialog.Filter = "xlsx files (*.*)|*.xlsx"; if (dialog.ShowDialog() == DialogResult.OK) { string SavePath = Path.GetDirectoryName(dialog.FileName); string SaveFileName = this.txtSingleFileName.Text.Trim() == "" ? (Path.GetFileNameWithoutExtension(dialog.FileName) + "_圖號座標轉換.xlsx") : this.txtSingleFileName.Text + "_圖號座標轉換.xlsx"; TransCoordinateSystem TCS = new TransCoordinateSystem(); TCS.Main_start(dialog.FileName, SavePath, SaveFileName); MessageBox.Show("檔案處理完成!"); } }