R
Rishabh2908
Guest
Hello Everybody ,
I am getting the following error . can you please help me
Thanks in advance
DialogResult dr = openFileDialog1.ShowDialog();
if (dr == System.Windows.Forms.DialogResult.OK)
{
int ImgName = 99999999;
if (GridEmpl.SelectedRows.Count > 0)
ImgName = int.Parse(GridEmpl.SelectedRows[0].Cells[0].Value.ToString());
string TargetFile = config.EmplPhotoPath + "\\" + ImgName.ToString() + ".jpg";
string source = openFileDialog1.FileName;
if (pictureBoxEmpl.Image != null)
pictureBoxEmpl.Image.Dispose();
GC.Collect();
GC.WaitForPendingFinalizers();
GC.WaitForFullGCComplete();
if (File.Exists(TargetFile))
{
System.IO.File.Delete(TargetFile);
}
Bitmap tempBmp = new Bitmap(source);
float resizeparameter = float.Parse(tempBmp.Width.ToString()) / 400;
float fheight = tempBmp.Height / resizeparameter;
int height = Convert.ToInt32(fheight);
Bitmap bmp = new Bitmap(tempBmp, 400, height);
GC.Collect();
GC.WaitForPendingFinalizers();
bmp.Save(TargetFile, System.Drawing.Imaging.ImageFormat.Jpeg);
MessageBox.Show(" Zdjęcie zmienione");
tempBmp.Dispose();
bmp.Dispose();
}
}
Continue reading...
I am getting the following error . can you please help me
Thanks in advance
DialogResult dr = openFileDialog1.ShowDialog();
if (dr == System.Windows.Forms.DialogResult.OK)
{
int ImgName = 99999999;
if (GridEmpl.SelectedRows.Count > 0)
ImgName = int.Parse(GridEmpl.SelectedRows[0].Cells[0].Value.ToString());
string TargetFile = config.EmplPhotoPath + "\\" + ImgName.ToString() + ".jpg";
string source = openFileDialog1.FileName;
if (pictureBoxEmpl.Image != null)
pictureBoxEmpl.Image.Dispose();
GC.Collect();
GC.WaitForPendingFinalizers();
GC.WaitForFullGCComplete();
if (File.Exists(TargetFile))
{
System.IO.File.Delete(TargetFile);
}
Bitmap tempBmp = new Bitmap(source);
float resizeparameter = float.Parse(tempBmp.Width.ToString()) / 400;
float fheight = tempBmp.Height / resizeparameter;
int height = Convert.ToInt32(fheight);
Bitmap bmp = new Bitmap(tempBmp, 400, height);
GC.Collect();
GC.WaitForPendingFinalizers();
bmp.Save(TargetFile, System.Drawing.Imaging.ImageFormat.Jpeg);
MessageBox.Show(" Zdjęcie zmienione");
tempBmp.Dispose();
bmp.Dispose();
}
}
Continue reading...