wpf 對話方塊
阿新 • • 發佈:2019-02-07
4.messageBox 提示對話方塊SaveFileDialog saveFileDialog1 = new SaveFileDialog(); saveFileDialog1.Filter = "txt files (*.txt)|*.txt"; saveFileDialog1.FilterIndex = 2; saveFileDialog1.RestoreDirectory = true; if (saveFileDialog1.ShowDialog() == DialogResult.OK) { if ((myStream = saveFileDialog1.OpenFile()) != null) { using (StreamWriter sw = new StreamWriter(myStream)) { sw.Write("this is the text"); } myStream.Close(); MessageBox.Show("Saved"); } }
MessageBoxResult dr = MessageBox.Show("退出可能導致無法使用?"+"\r\n"+"是否退出", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Warning);
if (dr == MessageBoxResult.OK)
{
//新增一些操作
}