private void backgroundWorker1_work(object sender, DoWorkEventArgs e) { ftp ftpClient = new ftp(@"ftp://" + ipAddresseServeur, "launcher", "123456"); ftpClient.download(reponse.Split(' ')[0] + "\\jeu\\zip\\jeu.zip", "Jeu.zip", backgroundWorker1); }
private void miseAJour(string update, string version, string url) { //string update = @"C:\Users\adrie\OneDrive\Documents\DiffEngine_src\movie.json"; string[] lines = System.IO.File.ReadAllLines(update); List <filupdate> deserializedProduct = (List <filupdate>)JsonConvert.DeserializeObject(lines[0], typeof(List <filupdate>)); foreach (filupdate file in deserializedProduct) { if (file.Type == 0) { ftp ftpClient = new ftp(@"ftp://" + ipAddresseServeur, "launcher", "123456"); ftpClient.download(url + "\\jeu\\normal" + file.Fichier, @"." + file.Fichier, null); } else if (file.Type == 1) { try { string oldFile = "." + file.Fichier; string newFile = "." + file.Fichier + ".new"; string patchFile = "." + file.Updateur; using (FileStream input = new FileStream(oldFile, FileMode.Open, FileAccess.Read, FileShare.Read)) using (FileStream output = new FileStream(newFile, FileMode.Create)) BinaryPatchUtility.Apply(input, () => new FileStream(patchFile, FileMode.Open, FileAccess.Read, FileShare.Read), output); File.Delete("." + file.Fichier); File.Move(newFile, "." + file.Fichier); } catch (FileNotFoundException ex) { Console.Error.WriteLine("Could not open '{0}'.", ex.FileName); } } else if (file.Type == 2) { } else { MessageBox.Show("Error 203"); } } FileStream ver = new FileStream("version.txt", FileMode.OpenOrCreate, FileAccess.ReadWrite); ver.Write(System.Text.Encoding.UTF8.GetBytes(version), 0, System.Text.Encoding.UTF8.GetBytes(version).Length); ver.Close(); Directory.Delete("./patch", true); File.Delete("update.zip"); }