private void BtnImport_Click(object sender, RoutedEventArgs e) { var ofd = FileDialogFactory.GetOFD(DataFileInfo.ExcelSAndTxtFilter); if (!(bool)ofd.ShowDialog()) { return; } DataTable dt = null; switch (ofd.FilterIndex) { case 1: case 2: dt = ExcelIO.Read(ofd.FileName); break; case 3: dt = TxtIO.Read(ofd.FileName, ','); break; default: return; } if (dt == null) { return; } updateContext(new GroupListViewModel(dt)); FadeInOutTextBlockHelper.MakeFadeInOut(greenPromptTB, "导入成功"); }
private void webBrowserPathReference_Click(object sender, EventArgs e) { SmartPDA.Windows.Forms.OpenFileDialog fd = FileDialogFactory.MakeOpenFileDialog(); if (Directory.Exists(Path.GetDirectoryName(webBrowserPathTextBox2.Text.Trim()))) { fd.InitialDirectory = Path.GetDirectoryName(webBrowserPathTextBox2.Text.Trim()); } fd.Filter = "*.exe|*.exe|*.*|*.*"; fd.Activation = ItemActivation.OneClick; if (fd.ShowDialog() == DialogResult.OK) { webBrowserPathTextBox2.Text = fd.FileName; } fd.Dispose(); }
private void BtnExport_Click(object sender, RoutedEventArgs e) { var sfd = FileDialogFactory.GetSFD(DataFileInfo.ExcelSAndTxtFilter); if (!(bool)sfd.ShowDialog()) { return; } switch (sfd.FilterIndex) { case 1: case 2: ExcelIO.Write(sfd.FileName, rlvm.Table); break; case 3: TxtIO.Write(sfd.FileName, rlvm.Table, ','); break; default: return; } }
private void BtnExport_Click(object sender, RoutedEventArgs e) { var sfd = FileDialogFactory.GetSFD(DataFileInfo.ExcelSAndTxtFilter); if (!(bool)sfd.ShowDialog()) { return; } switch (sfd.FilterIndex) { case 1: case 2: ExcelIO.Write(sfd.FileName, glvm.Table); break; case 3: TxtIO.Write(sfd.FileName, glvm.Table, ','); break; default: return; } FadeInOutTextBlockHelper.MakeFadeInOut(greenPromptTB, "导出成功"); }
public FileSystem(IFileIO fileIo, FileDialogFactory fileDialogFactory) { _fileIo = fileIo ?? throw new ArgumentNullException(nameof(fileIo)); _fileDialogFactory = fileDialogFactory ?? throw new ArgumentNullException(nameof(fileDialogFactory));; }