Quantcast
Channel: Common Language Runtime Internals and Architecture forum
Viewing all articles
Browse latest Browse all 1710

Having a problem in OpenFileDialog in C#

$
0
0

private void btnSelectImage_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Title = "اختر صورة";
            ofd.Filter = "Images|*.jpg;*.png";
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                if(File.Exists(ofd.FileName))
                {
                    txtPathImage.Text = ofd.FileName;
                    Bitmap bmp = new Bitmap(Image.FromFile(txtPathImage.Text), new Size(100, 100));
                    picEmpImage.Image = bmp;
                }
            }
        }

when i run the application ... the OpenFileDialog do not open and show me this error message

An unhandled exception of type 'System.AccessViolationException' occurred in System.Windows.Forms.dll

Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

what i have to do !!??


Viewing all articles
Browse latest Browse all 1710

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>