I am writing an application to copy a specific folder from a network resource to a local computer after copying a shortcut is created, everything works. But there is an idea to make the Progress bar display when copying and it was possible to copy several applications at the same time, please help in implementing the idea. My code below
public static void RA1112(string begin_dir1, string end_dir1) { Directory.CreateDirectory("C:\\APPS\\RA1112"); begin_dir1 = "W:\\Program\\DIS\\RS\\RA1112"; end_dir1 = "C:\\APPS\\RA1112"; //ΠΠ΅ΡΡΠΌ Π½Π°ΡΡ ΠΈΡΡ
ΠΎΠ΄Π½ΡΡ ΠΏΠ°ΠΏΠΊΡ DirectoryInfo dir_inf = new DirectoryInfo(begin_dir1); //ΠΠ΅ΡΠ΅Π±ΠΈΡΠ°Π΅ΠΌ Π²ΡΠ΅ Π²Π½ΡΡΡΠ΅Π½Π½ΠΈΠ΅ ΠΏΠ°ΠΏΠΊΠΈ foreach (DirectoryInfo dir in dir_inf.GetDirectories()) { //ΠΡΠΎΠ²Π΅ΡΡΠ΅ΠΌ - Π΅ΡΠ»ΠΈ Π΄ΠΈΡΠ΅ΠΊΡΠΎΡΠΈΠΈ Π½Π΅ ΡΡΡΠ΅ΡΡΠ²ΡΠ΅Ρ, ΡΠΎ ΡΠΎΠ·Π΄Π°Π΅ΠΌ; if (Directory.Exists(end_dir1 + "C:\\APPS\\RA1112" + dir.Name) != true) { Directory.CreateDirectory(end_dir1 + "C:\\APPS\\RA1112" + dir.Name); } //Π Π΅ΠΊΡΡΡΠΈΡ (ΠΏΠ΅ΡΠ΅Π±ΠΈΡΠ°Π΅ΠΌ Π²Π»ΠΎΠΆΠ΅Π½Π½ΡΠ΅ ΠΏΠ°ΠΏΠΊΠΈ ΠΈ Π΄Π΅Π»Π°Π΅ΠΌ Π΄Π»Ρ Π½ΠΈΡ
ΡΠΎ-ΠΆΠ΅ ΡΠ°ΠΌΠΎΠ΅). RA1112(dir.FullName, end_dir1 + "C:\\APPS\\RA1112" + dir.Name); } //ΠΠ΅ΡΠ΅Π±ΠΈΡΠ°Π΅ΠΌ ΡΠ°ΠΉΠ»Ρ Π² ΠΏΠ°ΠΏΠΊΠ΅ ΠΈΡΡΠΎΡΠ½ΠΈΠΊΠ΅. foreach (string file in Directory.GetFiles(begin_dir1)) { //ΠΠΏΡΠ΅Π΄Π΅Π»ΡΠ΅ΠΌ (ΠΎΡΠ΄Π΅Π»ΡΠ΅ΠΌ) ΠΈΠΌΡ ΡΠ°ΠΉΠ»Π° Ρ ΡΠ°ΡΡΠΈΡΠ΅Π½ΠΈΠ΅ΠΌ - Π±Π΅Π· ΠΏΡΡΠΈ (Π½ΠΎ Ρ ΡΠ»Π΅ΡΠ΅ΠΌ "\"). string filik = file.Substring(file.LastIndexOf('\\'), file.Length - file.LastIndexOf('\\')); //ΠΠΎΠΏΠΈΡΡΠ΅ΠΌ ΡΠ°ΠΉΠ» Ρ ΠΏΠ΅ΡΠ΅Π·Π°ΠΏΠΈΡΡΡ ΠΈΠ· ΠΈΡΡΠΎΡΠ½ΠΈΠΊΠ° Π² ΠΏΡΠΈΡΠΌΠ½ΠΈΠΊ. File.Copy(file, end_dir1 + "\\" + filik, true); } var wsh = new WshShell(); var shortcut = wsh.CreateShortcut( Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\RA1112.lnk") as IWshShortcut; if (shortcut == null) return; // shortcut.Arguments = "c:\\app\\settings1.xml"; shortcut.TargetPath = "C:\\APPS\\RA1112\\COLVIR.exe"; // not sure about what this is for shortcut.WindowStyle = 1; shortcut.Description = "my shortcut description"; shortcut.WorkingDirectory = "C:\\APPS"; shortcut.IconLocation = "C:\\APPS\\RA1112\\COLVIR.exe"; shortcut.Save(); }
RA1112
is a terrible name for a method! ) - Kromster