private void menuDeleteVideo_Click(object sender, RoutedEventArgs e) {
if (MessageBox.Show("Are you sure you want to delete this video file?" + Environment.NewLine + video.FileName, "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) {
try {
business.DeleteFile(video.FileName);
video.FileName = null;
video.Length = null;
video.Height = null;
bool IsSaved = SaveChanges();
// If adding new record and deleting the file and can't save, we must close form
// to avoid duplicate record if downloading another video file.
if (isNew && !IsSaved) {
video.MediaId = Guid.Empty;
isFormSaved = true;
this.Close(); // A non-loaded window can still be closed...
}
} catch (Exception ex) {
string Msg = "The file cannot be deleted:\r\n" + ex.Message;
MessageBox.Show(Msg, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
}