} //this method copy the files and the folders private void moveElement(string[] source, string destination) { foreach (string item in source) { if (File.Exists(item)) { if (!File.Exists(Path.Combine(destination, Path.GetFileName(item)))) { File.Move(item, Path.Combine(destination, Path.GetFileName(item))); } else { AreYouSureForm newform2 = new AreYouSureForm("Biztos, hogy felülírja a Fájlokat?"); if (newform2.ShowDialog() == DialogResult.OK) { File.Delete(Path.Combine(destination, Path.GetFileName(item))); File.Move(item, Path.Combine(destination, Path.GetFileName(item))); } } } else { if (Directory.Exists(item)) { if (!File.Exists(Path.Combine(destination, Path.GetDirectoryName(item)))) { string newdirname = Path.Combine(destination, Path.GetFileName(item)); Directory.CreateDirectory(newdirname); string[] newitems = Directory.GetFileSystemEntries(item); moveElement(newitems, newdirname); Directory.Delete(item); } else { AreYouSureForm newform3 = new AreYouSureForm("Biztos, hogy felülírja a Mappa tartalmát?"); if (newform3.ShowDialog() == DialogResult.OK) { string newdirname = Path.Combine(destination, Path.GetDirectoryName(item)); Directory.CreateDirectory(newdirname); string[] newitems = Directory.GetFileSystemEntries(item); moveElement(newitems, newdirname); Directory.Delete(item); } } } } } } //this method move the files and the folders
} //constructor of the main form #region FunctionsAndMethods private void copyElement(string[] source, string destination) { foreach (string item in source) { string dest = Path.Combine(destination, Path.GetFileName(item)); copyBackground.ReportProgress(0); if (File.Exists(item)) { if (!File.Exists(Path.Combine(destination, Path.GetFileName(item)))) { File.Copy(item, Path.Combine(destination, Path.GetFileName(item)), true); } else { AreYouSureForm newform2 = new AreYouSureForm("Biztos, hogy felülírja a " + item + "?"); if (newform2.ShowDialog() == DialogResult.OK) { File.Copy(item, Path.Combine(destination, Path.GetFileName(item)), true); } } } else { if (Directory.Exists(item)) { if (!File.Exists(Path.Combine(destination, Path.GetDirectoryName(item)))) { string newdirname = Path.Combine(destination, Path.GetFileName(item)); Directory.CreateDirectory(newdirname); string[] newitems = Directory.GetFileSystemEntries(item); copyElement(newitems, newdirname); } else { AreYouSureForm newform3 = new AreYouSureForm("Biztos, hogy felülírja a " + item + "?"); if (newform3.ShowDialog() == DialogResult.OK) { string newdirname = Path.Combine(destination, Path.GetDirectoryName(item)); string[] newitems = Directory.GetFileSystemEntries(item); copyElement(newitems, newdirname); } } } } } } //this method copy the files and the folders
} //move button private void toolStripDeleteButton_Click(object sender, EventArgs e) { AreYouSureForm newform = new AreYouSureForm("Biztos, hogy törli kijelölt elemeket?"); if (this.ActiveMdiChild == LeftForm) { if (newform.ShowDialog() == DialogResult.OK) { if (LeftForm.IsChecked()) { source = LeftForm.BackTrails(); deleteBackground.RunWorkerAsync(); } else { MessageBox.Show("Még nem választott ki elemet!"); } } //LeftForm.PopulateList(); //RightForm.PopulateList(); } else { if (this.ActiveMdiChild == RightForm) { if (newform.ShowDialog() == DialogResult.OK) { if (RightForm.IsChecked()) { source = RightForm.BackTrails(); deleteBackground.RunWorkerAsync(); //foreach (string element in RightForm.BackTrails()) //{ // if (Path.HasExtension(element)) // { // File.Delete(element); // } // else // { // try // { // Directory.Delete(element); // } // catch (IOException iex) // { // MessageBox.Show(iex.Message); // } // } //} } else { MessageBox.Show("Még nem választott ki elemet!"); } } //LeftForm.PopulateList(); //RightForm.PopulateList(); } } } //delete button