private void editButton_Click(object sender, EventArgs e) { SaveFileDialog saveFileDialog = new SaveFileDialog(); ShowSaveFileDialogInvoker invoker = new ShowSaveFileDialogInvoker(saveFileDialogMethod); mainForm.activ.Invoke(invoker); }
private string SaveDialog(string ext) { string SaveFileName = string.Empty; SaveFileDialog DialogSave = new SaveFileDialog(); DialogSave.Filter = "*" + ext + "| *" + ext; DialogSave.AddExtension = true; DialogSave.RestoreDirectory = true; DialogSave.Title = "Where do you want to save the file?"; DialogSave.InitialDirectory = @"C:/"; ShowSaveFileDialogInvoker invoker = new ShowSaveFileDialogInvoker(DialogSave.ShowDialog); this.Invoke(invoker); SaveFileName = DialogSave.FileName; return(SaveFileName); }
} // ClientDoListen // Вызывает стандартный диалог сохранения файла и сохраняет private void SaveFile(NetFile f) { SaveFileDialog saveFileDialog = new SaveFileDialog() { InitialDirectory = @"d:\", Filter = $"(*{f.Extension})|*{f.Extension}|All files (*.*)|*.*", FileName = $"{f.FileName}", ValidateNames = true }; ShowSaveFileDialogInvoker invoker = saveFileDialog.ShowDialog; if (Invoke(invoker).Equals(DialogResult.Cancel)) return; string filename = saveFileDialog.FileName; File.WriteAllBytes(filename, f.Data); MessageBox.Show("File successfully saved!", "Save", MessageBoxButtons.OK, MessageBoxIcon.Information); } // SaveFile