public void S_FileCompare(C_DirectoryNode zRootNode) { List <string> zUpdateList = new List <string>(); foreach (var n in zRootNode.o_FileDic) { if (o_FileDic.ContainsKey(n.Key)) { if (n.Value > o_FileDic[n.Key]) { zUpdateList.Add(n.Key); } o_FileDic[n.Key] = 0; } else { zUpdateList.Add(n.Key); } } List <string> zDeleteLIst = new List <string>(); foreach (var n in o_FileDic) //获取删除列表--------- { if (n.Value != 0) { zDeleteLIst.Add(n.Key); } } foreach (var n in zDeleteLIst) //删除文件----------- { string zTargetPath = o_Path + "\\" + n; Console.WriteLine("删除_" + zTargetPath); try { File.Delete(zTargetPath); } catch (Exception ex) { Console.WriteLine("文件删除失败_" + zTargetPath + "__" + ex.Message); } } foreach (var n in zUpdateList) //拷贝更新文件---------- { string zSourcePath = zRootNode.o_Path + "\\" + n; string zTargetPath = o_Path + "\\" + n; if (File.Exists(zTargetPath)) { File.Delete(zTargetPath); } string zDirectory = Path.GetDirectoryName(zTargetPath); if (Directory.Exists(zDirectory) == false) { Directory.CreateDirectory(zDirectory); } Console.WriteLine("拷贝_" + zTargetPath); try { S_大文件流拷贝(zSourcePath, zTargetPath); } catch (Exception ex) { Console.WriteLine("文件拷贝失败_" + zTargetPath + "__" + ex.Message); } } }
public C_CopyChain链(string[] sss) { rootNode = new C_DirectoryNode(sss[0].Trim()); Console.WriteLine("ddddddddddddd_____dd______" + sss[0]); for (int i = 1; i < sss.Length; i++) { Console.WriteLine("ddddddddddddd________w___" + sss[i]); if (sss[i][0] != '#') { nodeList.Add(new C_DirectoryNode(sss[i].Trim())); } } }