예제 #1
0
        public void SaveDialog(SaveFileMessage msg)
        {
            var dlg = new SaveFileDialog();

            dlg.Filter       = "Text Files (*.txt)|*.txt";
            dlg.DefaultExt   = "txt";
            dlg.AddExtension = true;
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                if (msg.OpenStream)
                {
                    using (var stream = dlg.OpenFile())
                    {
                        msg.OpenStreamAction(stream);
                    }
                }
                else
                {
                    msg.PassFileNameAction(dlg.FileName);
                }
            }
        }
예제 #2
0
        public async void SaveDialog(SaveFileMessage msg)
        {
            var dlg = new SaveFileDialog();

            dlg.DefaultExtension = "*.txt";
            //dlg.Filter = "Text Files (*.txt)|*.txt";
            var result = await dlg.ShowAsync(null);

            if (!string.IsNullOrWhiteSpace(result))
            {
                if (msg.OpenStream)
                {
                    using (var stream = new FileStream(result, FileMode.OpenOrCreate))
                    {
                        msg.OpenStreamAction(stream);
                    }
                }
                else
                {
                    msg.PassFileNameAction(result);
                }
            }
        }