C# 開檔對話盒(OpenFileDialog) / 存檔對話盒(SaveFileDialog)

C# 開檔對話盒(OpenFileDialog) / 存檔對話盒(SaveFileDialog)

C# 開檔對話盒(OpenFileDialog) / 存檔對話盒(SaveFileDialog)


開檔對話盒:

                OpenFileDialog openFileDialog1 = new OpenFileDialog();
                openFileDialog1.Filter = “SYWEB_Backup|*.bak”;
                openFileDialog1.Title = “Open an Backup”;
                openFileDialog1.RestoreDirectory = true ;
                if (openFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    StrPath = openFileDialog1.FileName.ToString();
                }

存檔對話盒
                    SaveFileDialog saveFileDialog1 = new SaveFileDialog();
                    saveFileDialog1.Filter = “Backup|*.bak”;
                    saveFileDialog1.Title = “Save an Backup”;
                    String StrName = String.Format(“Backup_{0}_{1}”, m_ver, DateTime.Now.ToString(“yyyyMMdd”));
                    saveFileDialog1.FileName = StrName; // Default file name
                    saveFileDialog1.DefaultExt = “.bak”; // Default file extension
                    if (saveFileDialog1.ShowDialog() == DialogResult.OK)
                    {
                        
                        StrPath=saveFileDialog1.FileName.ToString();
                    }


 


One thought on “C# 開檔對話盒(OpenFileDialog) / 存檔對話盒(SaveFileDialog)

發表迴響

你的電子郵件位址並不會被公開。 必要欄位標記為 *