I have this code:
DialogResult dr = ofd1.ShowDialog();
Moving to WPF does not work. I searched the internet and found nothing yet, that satisfies me. How do I replace in WPF?
Note: ofd1 is a OpenDialog
I have this code:
DialogResult dr = ofd1.ShowDialog();
Moving to WPF does not work. I searched the internet and found nothing yet, that satisfies me. How do I replace in WPF?
Note: ofd1 is a OpenDialog
Use MessageResult
MessageBoxResult result = MessageBox.Show("Questão", "Título", MessageBoxButton.YesNo, MessageBoxImage.Question);
if (result == MessageBoxResult.Yes)
{
// Fazer algo
}
So it worked:
Nullable<bool> result = ofd1.ShowDialog();
if(result == true)
{
try
{
LocalizacaoZip = ofd1.FileName;
nome_arquivo_zip = System.IO.Path.GetFileNameWithoutExtension(ofd1.FileName);
}
catch (SecurityException ex)
{
}
catch(Exception ex)
{ }
}
How do you compare the OpenFileDialog result? The code below works perfectly for me ..
using System;
using System.Windows.Forms;
namespace TesteWpf {
class Program {
[STAThread]
static void Main(string[] args) {
using (OpenFileDialog ofd = new OpenFileDialog()) {
if (ofd.ShowDialog() == DialogResult.OK) {
}
}
}
}
}