/// <summary> /// method for change file /// </summary> /// <param name="files"></param> /// <param name="newPath"></param> /// <param name="parent"></param> /// <param name="flag"></param> /// <param name="cp"></param> public void ChangeFiles(List <string> files, string newPath, List <string> parent, bool flag, Copy cp) { bool flagchange = false; int index = 0; int count = 1; string path = string.Empty; int value = 0; foreach (var file in files) { if (!file.Contains(parent[index])) { index++; } MediatorProgressBar.Name(file.Remove(0, file.LastIndexOf('\\') + 1)); if (!flag) { path = string.Format("{0}{1}", newPath, file.Remove(0, parent[index].Length + 1)); Copy.CopyFile(file, path, ref flagchange, cp); } else { Delete.DeleteFile(file); } value = count * 100 / files.Count; MediatorProgressBar.Count(value); count++; } }
/// <summary> /// method for delete content /// </summary> private void DeleteContend() { this.thread = new Thread((object y) => { try { this.delcont.AddContent(); this.delcont.StartDelete(); this.delcont.Reset(); MediatorProgressBar.GetRoot(this.root); MediatorProgressBar.Count(100); MediatorProgressBar.Close(); } catch (Exception e) { try { MessageBox.Show(string.Format("Access is denied {0}", e.Message.Remove(0, e.Message.IndexOf('"'))), "Delete", MessageBoxButton.OK, MessageBoxImage.Error); } catch (Exception ex) { } MediatorProgressBar.Count(100); MediatorProgressBar.Close(); } }); thread.Start(); }
/// <summary> /// method for copy content /// </summary> private void CopyContent() { this.thread = new Thread((object y) => { try { this.copyCont.AddContent(); this.copyCont.StartCopy(); MediatorProgressBar.GetRoot(this.root); MediatorProgressBar.Count(100); MediatorProgressBar.Close(); } catch (Exception e) { this.copyCont.ErrorDelete(); MessageBox.Show(e.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); MediatorProgressBar.GetRoot(this.root); MediatorProgressBar.Count(100); MediatorProgressBar.Close(); } }); thread.Start(); }