private void UpdateFileList() { lstFiles.Nodes.Clear(); filesToSync.Clear(); foreach (BUFile data in WorkspacesData) { TreeNode node = data.getTree(true, this); if (node == null) { break; } if (lstFiles.Nodes.Contains(node)) { int i = lstFiles.Nodes.IndexOf(node); TreeNode fused = BUFile.fuseTrees(lstFiles.Nodes[i], node); if (fused == null) { break; } lstFiles.Nodes[i] = fused; } else { lstFiles.Nodes.Add(node); } } }
private List <string> getWSFileList() { List <string> retrun = new List <string>(); WorkspacesData.ForEach((BUFile folder) => { List <string> test = makeFileList(BUFile.GetNodePath(folder.getTree())); if (test != null) { retrun.AddRange(test); } }); return(retrun); }
private List <string> getWSFolders() { List <string> retrun = new List <string>(); foreach (BUFile folder in WorkspacesData) { string fd = BUFile.GetNodePath(folder.getTree()); if (Directory.Exists(fd)) { retrun.Add(fd); } } return(retrun); }
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(); } }