//更新操作 public void doUpdate() { download(); //读取配置文件并进行操作 DirectoryInfo fileFold = new DirectoryInfo(downloadPath); FileInfo[] files = fileFold.GetFiles(); string PcPath = current + "\\PC"; string IniName = ""; for (int i = 0; files != null && i < files.Length; i++) //将文件信息添加到List里面 { if (files[i].Extension == ".ini") //挑选出符合条件的信息 { IniName = files[i].Name; IniFiles ini_file_read = new IniFiles(downloadPath + "\\" + files[i].Name); for (int j = 0; j < 10000; j++) { String tem_path = "session" + j.ToString(); String tem_file_name = ini_file_read.IniReadvalue(tem_path, "fileName"); String tem_file_updateMethod = ini_file_read.IniReadvalue(tem_path, "updateMethod"); if (tem_file_updateMethod == "") { break; } else if (tem_file_updateMethod == "新增") { System.IO.File.Copy(downloadPath + "\\" + tem_file_name, PcPath + "\\" + tem_file_name, true); } else if (tem_file_updateMethod == "删除") { System.IO.File.Delete(PcPath + "\\" + tem_file_name); } else if (tem_file_updateMethod == "替换") { //先删除后复制 System.IO.File.Delete(PcPath + "\\" + tem_file_name); System.IO.File.Copy(downloadPath + "\\" + tem_file_name, PcPath + "\\" + tem_file_name, true); } } break; } } //更新PC的ini DirectoryInfo Fold = new DirectoryInfo(PcPath); FileInfo[] fs = Fold.GetFiles(); for (int i = 0; fs != null && i < fs.Length; i++) //将文件信息添加到List里面 { if (fs[i].Extension == ".ini") //挑选出符合条件的信息 { Console.WriteLine(PcPath + "\\" + fs[i].Name); //删除原来的 System.IO.File.Delete(PcPath + "\\" + fs[i].Name); break; } } //复制新的进去 System.IO.File.Copy(downloadPath + "\\" + IniName, PcPath + "\\" + IniName, true); }