Upload a Picture in WPF UI

 Uploading Picture in UI is very Important It is Quite Easy. On upload button Event Write down The following code:

                OpenFileDialog dlg;
                FileStream fs;
               byte[] data;

              dlg = new Microsoft.Win32.OpenFileDialog();

              dlg.ShowDialog();
               if (dlg.FileName == "")
            {
                MessageBox.Show("Picture is not selected......");
            }
            else
            {
                fs = new FileStream(dlg.FileName, FileMode.Open, FileAccess.Read);


                data = new byte[fs.Length];
                fs.Read(data, 0, System.Convert.ToInt32(fs.Length));


                fs.Close();
                ImageSourceConverter imgs = new ImageSourceConverter();
                SupplierLogoimage.SetValue(Image.SourceProperty, imgs.ConvertFromString(dlg.FileName.ToString()));


EnJoy....... !!

Popular posts from this blog

mvc razor textboxfor change event change another textboxfor value

WPF Crystal Report Viewer Using SAP

ASP.NET MVC razor SAP Crystal report