private void bbixls_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { sfd.Filter = "Excel Dosyası (*.xls)|*.xls"; if (sfd.ShowDialog() == DialogResult.OK) { grdStock.ExportToXls(sfd.FileName); } sfd.Reset(); }
private void bbixls_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { DataTable dtFill = db.GetDataTable(sql); gridControl1.DataSource = dtFill; sfd.Filter = "Excel Dosyası (*.xls)|*.xls"; if (sfd.ShowDialog() == DialogResult.OK) { gridView1.ExportToXls(sfd.FileName); } sfd.Reset(); FillData(); }
private void cmdBrowse_Click(object sender, EventArgs e) { // Show the save box if (lvTemplates.SelectedItems.Count == 0) { MessageBox.Show("Please select a template to use before setting the file to save.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } string fileExtension = Path.GetExtension(lvTemplates.SelectedItems[0].Tag.ToString().Split('|')[1]); Directory.SetCurrentDirectory(g.Project.ProjectPath); SaveFileDialog sfd = new SaveFileDialog(); sfd.RestoreDirectory = true; sfd.Title = "Add New Item"; sfd.Filter = "*" + fileExtension + " Files|*" + fileExtension + "|All Files (*.*)|*.*"; sfd.OverwritePrompt = true; sfd.CheckPathExists = true; DialogResult result = sfd.ShowDialog(this); if (result == DialogResult.Cancel) { return; } txtSaveTo.Text = sfd.FileName; sfd.Reset(); }
private void OnButtonSaveClick(object obj, EventArgs args) { SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = "(*.mdb)|*.mdb"; if (saveFileDialog.ShowDialog() == DialogResult.OK) { string dbFileName = saveFileDialog.FileName; saveFileDialog.Reset(); dataBase = new DataBase(); dataBase.myConnection = new OleDbConnection(dataBase.connectString); dataBase.myConnection.Open(); for (int i = 0; i < listCarsSold.Count; i++) { string query = "INSERT INTO Cars (w_CarBrand, w_Color, w_YearOfRelease, w_DateOfSale, w_Amount) VALUES ("; query += @"'" + listCarsSold[i].CarBrand + @"', '" + listCarsSold[i].Color + @"', " + listCarsSold[i].YearOfRelease + @",'" + listCarsSold[i].DateOfSale.ToString().Split(' ')[0] + @"', " + listCarsSold[i].Amount + ")"; OleDbCommand dbCommand = new OleDbCommand(query, dataBase.myConnection); if (i == 0) { new OleDbCommand("DELETE FROM Cars WHERE w_id", dataBase.myConnection).ExecuteNonQuery(); } dbCommand.ExecuteNonQuery(); } dataBase.myConnection.Close(); FileInfo fileInf = new FileInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Cars.mdb")); if (fileInf.Exists) { fileInf.CopyTo(dbFileName, true); } } }
public void Save(FastColoredTextBox fctb, bool force) { if (fctb.Tag == null || force) { SaveFileDialog save = new SaveFileDialog(); save.Reset(); save.RestoreDirectory = true; save.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); save.Filter = "Function (*.mcfunction)|*.mcfunction|Json (*.json; *.mcmeta)|*.json; *.mcmeta"; save.AddExtension = true; save.SupportMultiDottedExtensions = false; if (save.ShowDialog() == DialogResult.OK) { fctb.Tag = save.FileName; fctb.SaveToFile(save.FileName, new UTF8Encoding(false)); FATabStripItem item = (FATabStripItem)fctb.Parent; item.Title = Path.GetFileName(save.FileName); FileSystem.SaveRecent(save.FileName); lstbRecents.Items.Add(save.FileName); } } else { string file = fctb.Tag.ToString(); fctb.SaveToFile(file, new UTF8Encoding(false)); FATabStripItem item = (FATabStripItem)fctb.Parent; item.Title = Path.GetFileName(file); } }
public void SaveWithDialog(IFileType fileType, string content) { _dialog.Filter = fileType.FilterPattern; if (_dialog.ShowDialog() == DialogResult.OK) { WriteToFile(_dialog.FileName, content); } _dialog.Reset(); }
/// <summary>ファイルを保存 ダイアログの表示用 helper</summary> /// <param name="initialDirectory">初期フォルダ</param> /// <param name="fileName">ファイル名</param> /// <param name="filePath">決定したファイル名</param> /// <param name="filter">保存するファイル種別</param> /// <param name="index">初期表示するファイル種別</param> /// <param name="confirmMessagging">出力確認のメッセージ</param> /// <param name="cancellationMessaging">出力キャンセルのメッセージ</param> /// <returns></returns> protected bool ShowSaveFileDialog(string initialDirectory, string fileName, out string filePath, string filter = "すべてのファイル (*.*)|*.*|CSVファイル (*.csv)|*.csv", int index = 2, Func <bool> confirmMessagging = null, Action cancellationMessaging = null) { filePath = string.Empty; var result = false; if (!IsConfirmRequired) { confirmMessagging = null; } if (LimitAccessFolder) { List <string> filesPath; result = ShowRootFolderBrowserDialog(initialDirectory, out filesPath, FolderBrowserType.SaveFile, fileName, confirmMessagging, cancellationMessaging); filePath = filesPath?.FirstOrDefault() ?? string.Empty; return(result); } using (var dialog = new SaveFileDialog()) { dialog.Reset(); dialog.InitialDirectory = initialDirectory; dialog.FileName = fileName; dialog.Filter = filter; dialog.FilterIndex = index; if (this.FileSelected(dialog, dialog.ShowDialog(ParentForm)) != DialogResult.OK || !(confirmMessagging?.Invoke() ?? true)) { cancellationMessaging?.Invoke(); return(result); } try { filePath = dialog.FileName; result = !string.IsNullOrEmpty(filePath); } catch (System.IO.IOException) { ShowWarningDialog(Constants.MsgWngPathTooLong); } } return(result); }
private void buttonExecuteAction_Click(object sender, EventArgs e) { if (comboBoxAction.SelectedIndex == 0) { Thread thread = new Thread(() => GetActors()); thread.Start(); } else if (comboBoxAction.SelectedIndex == 1) { Thread thread = new Thread(() => GetDirectors()); thread.Start(); } else if (comboBoxAction.SelectedIndex == 2) { SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Reset(); saveFileDialog.InitialDirectory = @"C:\Users\Yvens\Documents\GitHub\DisciplinaAprendizado\Codes\ImdbCrawler\CSV files\"; saveFileDialog.Filter = "arff files (*.arff)|*.arff"; saveFileDialog.FilterIndex = 1; saveFileDialog.RestoreDirectory = true; string path = ""; if (saveFileDialog.ShowDialog() == DialogResult.OK) { path = saveFileDialog.FileName; Thread thread = new Thread(() => ExportToWeka(path)); thread.Start(); } } else if (comboBoxAction.SelectedIndex == 3) { Thread thread = new Thread(() => GetMovieTags()); thread.Start(); } else if (comboBoxAction.SelectedIndex == 4) { Thread thread = new Thread(() => MoviesArithmetic()); thread.Start(); } else if (comboBoxAction.SelectedIndex == 5) { Thread thread = new Thread(() => RemoveSurfeit()); thread.Start(); } else if (comboBoxAction.SelectedIndex == 6) { Thread thread = new Thread(() => GetByGenre()); thread.Start(); } }
private void bbixls_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (xtraTabControl1.SelectedTabPage.Text.ToString() == "Tüm İzinler") { sfd.Filter = "Excel Dosyası (*.xls)|*.xls"; if (sfd.ShowDialog() == DialogResult.OK) { grdAll.ExportToXls(sfd.FileName); } } if (xtraTabControl1.SelectedTabPage.Text.ToString() == "Gelecek İzinler") { sfd.Filter = "Excel Dosyası (*.xls)|*.xls"; if (sfd.ShowDialog() == DialogResult.OK) { grdNext.ExportToXls(sfd.FileName); } } if (xtraTabControl1.SelectedTabPage.Text.ToString() == "Aktif İzinler") { sfd.Filter = "Excel Dosyası (*.xls)|*.xls"; if (sfd.ShowDialog() == DialogResult.OK) { grdNow.ExportToXls(sfd.FileName); } } if (xtraTabControl1.SelectedTabPage.Text.ToString() == "Geçmiş İzinler") { sfd.Filter = "Excel Dosyası (*.xls)|*.xls"; if (sfd.ShowDialog() == DialogResult.OK) { grdPast.ExportToXls(sfd.FileName); } } sfd.Reset(); }
/// <summary> /// Open a savefiledialogbox with the specified extension list and the specified default name. /// </summary> /// <param name="dialog"></param> /// <param name="extensionWithoutDot"></param> /// <param name="defaultname"></param> /// <returns>The selected file, or <see cref="String.Empty"/> if no file was selected.</returns> public static string GetSaveFileName(SaveFileDialog dialog, string extensionWithoutDot, string defaultname) { dialog.Reset(); dialog.OverwritePrompt = true; dialog.Title = "Save File As"; dialog.Filter = string.Format("{0} files (*.{0})|*.{0}|All files (*.*)|*.*", extensionWithoutDot); dialog.DefaultExt = extensionWithoutDot; dialog.FileName = defaultname; dialog.ShowDialog(); if (dialog.FileName.Length == 0) { return(""); } return(dialog.FileName); }
public void SaveFileDialog_Reset_Invoke_Success() { using var dialog = new SaveFileDialog { CheckWriteAccess = false, CreatePrompt = true, ExpandedMode = false, OverwritePrompt = false }; dialog.Reset(); Assert.True(dialog.CheckWriteAccess); Assert.False(dialog.CreatePrompt); Assert.True(dialog.ExpandedMode); Assert.True(dialog.OverwritePrompt); }
private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { SaveFileDialog sfd = new SaveFileDialog(); sfd.Filter = "Excel Dosyası (*.xlsx)|*.xlsx"; if (sfd.ShowDialog() == DialogResult.OK) { grdGrid.Columns[0].Visible = false; grdGrid.Columns[2].Visible = false; grdGrid.ExportToXlsx(sfd.FileName); } grdGrid.Columns[0].Visible = true; grdGrid.Columns[2].Visible = true; sfd.Reset(); }
private void button_Save_Click(object sender, EventArgs e) { SaveFileDialog sfd = null; Stream stream = null; sfd = FileSave(); if (sfd.ShowDialog() == DialogResult.OK) { stream = sfd.OpenFile(); StreamWriter sw = new StreamWriter(stream); } else { sfd.Reset(); sfd.Dispose(); } }
public void Reset() { SaveFileDialog sfd = new SaveFileDialog(); sfd.AddExtension = false; sfd.CheckFileExists = true; sfd.CheckPathExists = false; sfd.CreatePrompt = true; sfd.DefaultExt = "txt"; sfd.DereferenceLinks = false; sfd.FileName = "default.build"; sfd.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*"; sfd.FilterIndex = 5; sfd.InitialDirectory = Path.GetTempPath(); sfd.OverwritePrompt = false; sfd.RestoreDirectory = true; sfd.ShowHelp = true; sfd.Title = "Saving"; sfd.ValidateNames = false; sfd.Reset(); Assert.IsTrue(sfd.AddExtension, "#1"); Assert.IsFalse(sfd.CheckFileExists, "#2"); Assert.IsTrue(sfd.CheckPathExists, "#3"); Assert.IsFalse(sfd.CreatePrompt, "#4"); Assert.IsNotNull(sfd.DefaultExt, "#5"); Assert.AreEqual(string.Empty, sfd.DefaultExt, "#6"); Assert.IsTrue(sfd.DereferenceLinks, "#7"); Assert.IsNotNull(sfd.FileName, "#8"); Assert.AreEqual(string.Empty, sfd.FileName, "#9"); Assert.IsNotNull(sfd.FileNames, "#10"); Assert.AreEqual(0, sfd.FileNames.Length, "#11"); Assert.IsNotNull(sfd.Filter, "#12"); Assert.AreEqual(string.Empty, sfd.Filter, "#13"); Assert.AreEqual(1, sfd.FilterIndex, "#14"); Assert.IsNotNull(sfd.InitialDirectory, "#15"); Assert.AreEqual(string.Empty, sfd.InitialDirectory, "#16"); Assert.IsTrue(sfd.OverwritePrompt, "#17"); Assert.IsFalse(sfd.RestoreDirectory, "#18"); Assert.IsFalse(sfd.ShowHelp, "#19"); Assert.IsNotNull(sfd.Title, "#20"); Assert.AreEqual(string.Empty, sfd.Title, "#21"); Assert.IsTrue(sfd.ValidateNames, "#22"); }
public bool SaveFile(string extensionDescription, string extension, out string filePath) { _saveFileDialog.Reset(); _saveFileDialog.Filter = extensionDescription; _saveFileDialog.DefaultExt = extension; _saveFileDialog.OverwritePrompt = true; _saveFileDialog.AddExtension = true; var dialogResult = _saveFileDialog.ShowDialog(); if (dialogResult.HasValue && dialogResult.Value) { filePath = _saveFileDialog.FileNames[0]; return(true); } filePath = null; return(false); }
/// <summary> /// 指定したディレクトリにファイルを保存するディレクトリを開く。 /// </summary> /// <param name="Title">ダイアログのタイトル</param> /// <param name="InitialDirectory">ダイアログ表示時に示すディレクトリ</param> /// <param name="Filter">保存するファイルの形式(拡張子)</param> /// <returns>保存したファイルのパス</returns> public string SaveDialog(string Title, string InitialDirectory, string Filter) { string filePath = ""; SaveFileDialog sFD = new SaveFileDialog(); sFD.Title = Title; sFD.InitialDirectory = InitialDirectory; sFD.FileName = ""; sFD.Filter = Filter; sFD.FilterIndex = 1; sFD.RestoreDirectory = true; sFD.ShowHelp = true; sFD.ShowDialog(); filePath = sFD.FileName; sFD.Reset(); sFD.Dispose(); return(filePath); }
public static bool ExportDatabase() { try { SaveFileDialog saveFileDialog1 = new SaveFileDialog(); string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); saveFileDialog1.InitialDirectory = path; saveFileDialog1.Filter = "Database Files (*.db)|*.db|All files (*.*)|*.*"; saveFileDialog1.Title = "Select the location to back up the database file."; saveFileDialog1.DefaultExt = "db"; saveFileDialog1.CheckPathExists = true; saveFileDialog1.FileName = "Stock" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".db"; if (saveFileDialog1.ShowDialog() == DialogResult.OK) { if (saveFileDialog1.FileName != "") { File.Copy(@"Databases/Stock.db", saveFileDialog1.FileName, true); } else { return(false); } } else { return(false); } saveFileDialog1.Reset(); return(true); } catch (IOException IOThrow) { return(false); } }
private void Button_SaveUdzialy_Click(object sender, RoutedEventArgs e) { SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Title = "Save As..."; saveFileDialog.Filter = "bmp (*.bmp)|*.bmp"; saveFileDialog.InitialDirectory = "C:\\Users\\Hubi\\Desktop\\Ten semestr\\Pody\\Kryptografia Wizualna"; if (saveFileDialog.ShowDialog() == true) { udzial_1.Save(saveFileDialog.FileName); } saveFileDialog.Reset(); saveFileDialog.Title = "Save As..."; saveFileDialog.Filter = "bmp (*.bmp)|*.bmp"; saveFileDialog.InitialDirectory = "C:\\Users\\Hubi\\Desktop\\Ten semestr\\Pody\\Kryptografia Wizualna"; if (saveFileDialog.ShowDialog() == true) { udzial_2.Save(saveFileDialog.FileName); } }
private void BtnExport_Click(object sender, EventArgs e) { try { SaveFileDialog saveFileDialog1 = new SaveFileDialog(); saveFileDialog1.Filter = "Word Doc|*.docx"; saveFileDialog1.Title = "Save document File"; if (saveFileDialog1.ShowDialog() == DialogResult.OK && saveFileDialog1.FileName != "") { olist = new OrderList[getSize()]; if (dbCon.IsConnect()) { string orders = "SELECT `order_id`, `order_date_placed`, `customer`.`customer_first`, `order_total`, `order_status`.`order_status_name`, `customer`.`customer_last` " + "FROM `order`, `customer`, `order_status` " + "WHERE `order`.`customer_id` = `customer`.`customer_id` AND `order`.`order_status_id` = `order_status`.`order_status_id` AND `order_status`.`order_status_name` = 'Ready'"; var command = new MySqlCommand(orders, dbCon.Connection); var reader = command.ExecuteReader(); while (reader.Read()) { olist[each] = new OrderList(Convert.ToInt32(reader[0]), reader[5].ToString() + ", " + reader[2].ToString(), Convert.ToDateTime(reader[1]), Convert.ToDecimal(reader[3]), reader[4].ToString()); each++; } reader.Close(); } Microsoft.Office.Interop.Word.Application winword = new Microsoft.Office.Interop.Word.Application(); //Set animation status for Word application //winword.ShowAnimation = false; winword.Visible = false; object missing = System.Reflection.Missing.Value; Document document = winword.Documents.Add(ref missing, ref missing, ref missing, ref missing); //Add header into the document foreach (Section section in document.Sections) { Range headerRange = section.Headers[WdHeaderFooterIndex.wdHeaderFooterPrimary].Range; headerRange.Fields.Add(headerRange, WdFieldType.wdFieldPage); headerRange.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphCenter; headerRange.Font.ColorIndex = WdColorIndex.wdBlack; headerRange.Font.Size = 15; headerRange.Text = "ORDERS TO BE PREPARED"; } foreach (Section wordSection in document.Sections) { Range footer = wordSection.Footers[WdHeaderFooterIndex.wdHeaderFooterPrimary].Range; footer.Font.ColorIndex = WdColorIndex.wdBlack; footer.Font.Size = 10; footer.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphCenter; footer.Text = "ORDERS"; } document.Content.SetRange(0, 0); //document.Content.Text = "This is test document " + Environment.NewLine; //Adding Paragraph with Heading 1 Style Paragraph para1 = document.Content.Paragraphs.Add(ref missing); object styleHeading1 = "Heading 1"; para1.Range.set_Style(ref styleHeading1); para1.Range.Font.Size = 12; para1.Range.Text = "The following tables contains a list of all the orders which are to be prepared!"; para1.Range.InsertParagraphAfter(); //Create a 5X5 table and insert some dummy record Table firstTable = document.Tables.Add(para1.Range, getSize(), 5, ref missing, ref missing); firstTable.Borders.Enable = 1; int eachRow = 0; foreach (Row row in firstTable.Rows) { foreach (Cell cell in row.Cells) { if (cell.RowIndex == 1) { if (cell.ColumnIndex == 1) { cell.Range.Text = "Order ID"; } else if (cell.ColumnIndex == 2) { cell.Range.Text = "Customer Name"; } else if (cell.ColumnIndex == 3) { cell.Range.Text = "Order Date"; } else if (cell.ColumnIndex == 4) { cell.Range.Text = "Order Total"; } else if (cell.ColumnIndex == 5) { cell.Range.Text = "Order Status"; } cell.Range.Font.Bold = 1; //other format properties goes here cell.Range.Font.Name = "Ebrima"; cell.Range.Font.Size = 10; //cell.Range.Font.ColorIndex = WdColorIndex.wdGray25; cell.Shading.BackgroundPatternColor = WdColor.wdColorGray25; //cell.Shading.ForegroundPatternColor = WdColor.wdColorWhite; cell.VerticalAlignment = WdCellVerticalAlignment.wdCellAlignVerticalBottom; cell.Range.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphCenter; } else { //Row Data if (cell.ColumnIndex == 1) { cell.Range.Text = olist[eachRow].getOrderID.ToString(); } else if (cell.ColumnIndex == 2) { cell.Range.Text = olist[eachRow].getCustomerName; } else if (cell.ColumnIndex == 3) { cell.Range.Text = olist[eachRow].getOrderDate.ToString(); } else if (cell.ColumnIndex == 4) { cell.Range.Text = "R" + olist[eachRow].getOrderTotal.ToString(); } else if (cell.ColumnIndex == 5) { cell.Range.Text = olist[eachRow].getOrderStatus; } } } eachRow++; } //Save the document object filename = saveFileDialog1.FileName; document.SaveAs2(ref filename); document.Close(ref missing, ref missing); document = null; winword.Quit(ref missing, ref missing, ref missing); winword = null; eachRow = 0; each = 0; olist = null; System.Diagnostics.Process.Start(saveFileDialog1.FileName); } else { saveFileDialog1.Reset(); } } catch (Exception error) { MessageBox.Show("Error: " + error.Message); } }