private void Dispose(bool disposing) { if (disposing) { if (_dialog != null) { _dialog.Dispose(); } } }
private void BtnDownloadAttachment_Click(object sender, RoutedEventArgs e) { try { if (CboAttachments.SelectedIndex == -1) { throw new Exception(null); } if (Pub.NetUse_Connect(Pub.Ticketing_KnowledgebaseFolder())) { var x = System.IO.File.Exists((CboAttachments.SelectedItem as ComboBoxItem).Tag.ToString()) ? true : false; if (x == true) { using (Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog cfd = new Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog() { IsFolderPicker = true, Title = "CSF TICKETING", InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) }) { if (cfd.ShowDialog() == Microsoft.WindowsAPICodePack.Dialogs.CommonFileDialogResult.Ok) { /// CHECK IF THERE'S DUPLICATE FILE ON THE DESTINATION FOLDER var _source = (CboAttachments.SelectedItem as ComboBoxItem).Tag.ToString(); var _filename = System.IO.Path.GetFileName(_source); var _dest_folder = cfd.FileName; var _destination_file = System.IO.Path.Combine(_dest_folder, _filename); if (!System.IO.File.Exists(_destination_file)) { System.IO.File.Copy(_source, _destination_file); } else { throw new Exception("Duplicate file found on folder/destination."); } System.Diagnostics.Process.Start(_dest_folder); } cfd.Dispose(); } } Pub.NetUse_Disconnect(Pub.Ticketing_KnowledgebaseFolder()); } } catch (Exception ex) { if (!string.IsNullOrEmpty(ex.Message)) { MessageBox.Show("Error : " + ex.Message, "CSF TICKETING", MessageBoxButton.OK, MessageBoxImage.Error); } return; } }