User Tools

Site Tools


Action disabled: source
prog:csharp:250226-005:index

How to save the file using save file dialog box (2025-02-26)

Local Backup

  • Example:
    System.Windows.Forms.SaveFileDialog saveFileDialog1;
    saveFileDialog1 = new System.Windows.Forms.SaveFileDialog();
    DialogResult dr=  saveFileDialog1.ShowDialog();
    if (dr==DialogResult.OK)
    {
        string filename = saveFileDialog1.FileName;
        //save file using stream.
    }
  • Example:
    SaveFileDialog oSaveFileDialog = new SaveFileDialog();
    oSaveFileDialog.Filter = "All files (*.*) | *.*";
    if (oSaveFileDialog.ShowDialog() == DialogResult.OK)
    {
        string fileName = oSaveFileDialog.FileName;
        string extesion = Path.GetExtension(fileName);
        switch (extesion)
        {
            case ".txt"://do something here 
                break;
            case ".xls"://do something here 
                break;
            default://do something here
                break;
        }
    }   
  • 4 person(s) visited this page until now.

prog/csharp/250226-005/index.txt · Last modified: 2025/02/26 13:12 (external edit)