private void Btn_UploadFile_Click(object sender, RoutedEventArgs e) { if (dialog != null && File.Exists(dialog.FileName)) { //Delete file if already exists policyManager.DeleteFile(policyId); byte[] fileBytes = File.ReadAllBytes(dialog.FileName); bool status = policyManager.AddFile(fileBytes, dialog.SafeFileName, policyId); if (status) { dialog = null; txt_SelectBox.Text = ""; MessageBox.Show("File uploaded successfully."); this.Close(); } else { dialog = null; txt_SelectBox.Text = ""; MessageBox.Show("Can't upload file now. Please try again later."); this.Close(); } return; } MessageBox.Show("Please select a file to upload."); return; }