private void addWSLocation(string loc) { bool found = false; foreach (BUFile file in WorkspacesData) { if (file.getLastFolder() == BUFile.GetPathArray(loc).Last()) { found = true; } } if (!found) { BUFile NewColl = new BUFile(loc); WorkspacesData.Add(NewColl); addLocation(loc, lstWorkSpaces); } else { ShowError("Un dossier avec le nom '" + BUFile.GetPathArray(loc).Last() + "' est déjà enregistré.", "Dossier existant"); } }
private void Synchronize() { List <string> src = param[0]; List <string> dest = param[1]; List <string> prefixes = param[2]; string filename = (prefixes[0].Contains(FILENAME) ? "" : (FILENAME + "\\")); syncStart(src.Count * dest.Count); try { dest.ForEach(strD => { string padding = ""; if (strD.Last() != '\\') { padding = "\\"; } if (!Directory.Exists(strD + padding + filename)) { Directory.CreateDirectory(strD + padding + filename); } src.ForEach(str => { string localPath = ""; int j; for (j = 0; j < prefixes.Count; j++) { if (str.Contains(prefixes[j])) { break; } } if (j >= prefixes.Count) { throw new IndexOutOfRangeException("Les fichiers et les dossiers ne concordent pas."); } string prefix = BUFile.GetPathArray(prefixes[j]).Last(); string file = BUFile.GetPathArray(str).Last(); localPath = str.Replace(file, "").Replace(prefixes[j], ""); string strDest = strD + padding + filename + prefix + localPath + file; if (File.Exists(strDest)) { File.Copy(str, strDest, true); } else { string[] path = BUFile.GetPathArray(strDest); string newPath = ""; for (int i = 0; i < path.Length - 1; i++) { if (i != 0) { newPath = newPath + "\\"; } newPath = newPath + path[i]; } Directory.CreateDirectory(newPath); File.Copy(str, strDest); } this.InvokeEx(f => f.pgbSync.PerformStep()); if (File.GetAttributes(str).HasFlag(FileAttributes.Archive)) { File.SetAttributes(str, (FileAttributes)(File.GetAttributes(str) - FileAttributes.Archive)); } }); }); } catch (Exception e) { ShowError(e.Message, "Erreur dans la Synchronisation"); } finally { syncEnd(); } }