Reputation: 7601
Hello I have used OpenFileDialog in WPF for opening file, when I used first time it will work fine but when I clicked again it will give me error like "Attempted to read or write protected memory. This is often an indication that other memory is corrupt" my code is look like
using System.Windows.Forms;
OpenFileDialog oldg = new OpenFileDialog();
oldg.Filter = "All files (*.*)|*.*|All files (*.*)|*.*";
oldg.RestoreDirectory = true;
oldg.Multiselect = true;
oldg.ShowDialog();
string file = oldg.FileName;
please help me out this.
Upvotes: 0
Views: 817
Reputation: 64959
It looks to me as if you're trying to use the Windows Forms version of the OpenFileDialog
control in a WPF application. You may have more luck using the WPF version of the control instead.
In other words, try replacing
using System.Windows.Forms;
with
using Microsoft.Win32;
Upvotes: 1