void SaveImage(bool IsSave) { picStudent.Image = null; string pathDirection = ""; string ImageName = ""; pathDirection = SystemProperties.ReadStudentImage(); ImageName = string.Format("{0}", txtStudentID.Text); try { if (picStudent.Image != null) { if (IsSave) { picStudent.Image.Save(@"" + pathDirection + ImageName + ".png"); } else { picStudent.Image = Image.FromFile(pathDirection + ImageName + ".png"); } } else if (!IsSave) { picStudent.Image = Image.FromFile(pathDirection + ImageName + ".png"); } } catch (Exception ex) { } }
void DeleteImage() { string pathDirection = ""; string ImageName = ""; pathDirection = SystemProperties.ReadStudentImage(); ImageName = string.Format("{0}{1}-{2}", txtStudentLastName.Text, txtStudentFirstName.Text, txtStudentID.Text); //picStudent.Image.d(@"" + pathDirection + ImageName + ".png"); File.Delete(string.Format("{0}{1}", pathDirection, ImageName)); }