Click here to Skip to main content
16,017,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
string text = @"file:\\\D:\\acer.jpg";
                        text = text.Replace(@"file:\\\", @"");
                        string userimagepath = AppDomain.CurrentDomain.BaseDirectory + text + ds.Tables[0].Rows[0][11].ToString();
                        if (!File.Exists(userimagepath))
                        {
                            picUserimage.Source = BitmapFromUri(new Uri(text));
                        }


What I have tried:

openFileDialog1.CheckFileExists = true;
          openFileDialog1.CheckPathExists = true;
          openFileDialog1.DefaultExt = ".jpg";
          openFileDialog1.Filter = "jpg files (*.jpg)|*.jpg| PNG files (*.png)|*.png";
          openFileDialog1.FilterIndex = 2;
          openFileDialog1.RestoreDirectory = true;
          if (openFileDialog1.ShowDialog() == true)
          {

              picUserimage.Source = new BitmapImage(new Uri("D:\\acer.jpg"));
          }
Posted
Comments
[no name] 17-Sep-22 14:57pm    
The image is not "in the grid"; it's in a reference you created and assigned to an image control's source. The "image" is a byte stream copied from a file; it doesn't need to be "shared"; any form can load it's own copy.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900