marxc88 Posted May 31, 2012 at 07:52 PM Report #459552 Posted May 31, 2012 at 07:52 PM Entao galera boa tarde, entao e assim, comecei a desenvolver um launcher em C# ele verifica o crc do cliente, e compara com um xml que tenho hospedado online.. e baixa os arquivos se necessario.. O problema que ele nao mostra qual arquivo esta baixando atualmente.. Tipo se eu tenho 5 arquivos para baixar, ele sempre mostra o nome do ultimo arquivo.. E eu queria que ele mostrasse o arquivo que esta baixando ... E se possivel em progressbar a percentagem, mas isso deve ser mais complicado š O Codigo esta aqui , ja tentei de tudo mas nao consigo de xeito algum.. using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.IO; using System.Collections; using System.Net; namespace Launcher { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { Form2 load = new Form2(); load.Show(); } private void button2_Click(object sender, EventArgs e) { CRC32 CRC = new CRC32(); FileStream fs; string[] fullPathFilelist = Directory.GetFiles(Application.StartupPath, "*", SearchOption.AllDirectories); Hashtable checksums = new Hashtable(); // Verifica todo crc de todos arquivos. for (int i = 0; i < fullPathFilelist.Length; i++) { string filename = fullPathFilelist[i].Replace(Application.StartupPath, ""); fs = new FileStream(fullPathFilelist[i], FileMode.Open, FileAccess.Read, FileShare.Read, 8192); checksums.Add(filename, CRC.getCRC32(fs)); fs.Close(); } button2.Visible = false; // Baixa o arquivo xml dos arquivos. this.lblStatus.Text = "A baixar Lista De Atualização..."; downloadFile(Globals.hashListLink, "patch.xml"); this.lblStatus.Text = "Verificando Arquivos..."; string arquivonome = "patch.xml"; // Compara arquivos e ve o que necessita baixar. ArrayList filesToDownload = new ArrayList(); try { TextReader patchReader = new StreamReader(arquivonome); string nextLine; while ((nextLine = patchReader.ReadLine()) != null) { string[] tmp = nextLine.Split(new char[] { '=' }); uint correctChecksum = UInt32.Parse(tmp[1]); if ((!checksums.Contains(tmp[0])) || ((uint)checksums[tmp[0]] != correctChecksum)) filesToDownload.Add(tmp[0]); } patchReader.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } if (filesToDownload.Count.ToString() == "1") { this.lblStatus.Text = "NĆ£o Necessita Update"; } else { this.label2.Text = filesToDownload.Count.ToString(); //Baixar todos arquivos necessaarios.. this.animTimer.Enabled = true; foreach (string s in filesToDownload) { //Mostra atualizando cliente this.lblStatus.Text = "Atualizando Cliente...Aguarde"; string url = Globals.patchDirectory + s.Replace('\\', '/'); //Nome Arquivos Mostra this.label1.Text = s; //Mostra numeros de arquivos this.label2.Text = filesToDownload.Count.ToString(); downloadFile(url, s); } this.animTimer.Enabled = false; //Terminou Update // this.lblStatus.Text = "Terminou Atualização } button2.Visible = true; } private void downloadFile(string fileAddress, string localName) { string newDirectory = ""; if (localName.Contains("\\")) { string[] tmp = localName.Split(new char[] { '\\' }); newDirectory = Application.StartupPath; for (int i = 0; i <= tmp.Length - 2; i++) newDirectory += tmp[i] + "\\"; if (!Directory.Exists(newDirectory)) { Directory.CreateDirectory(newDirectory); } localName = tmp[tmp.Length - 1]; } if (File.Exists(newDirectory + localName)) { try { File.Delete(newDirectory + localName); } catch { // Faz Nada } } WebClient client = new WebClient(); string path = newDirectory + localName; client.Headers.Clear(); client.DownloadFileAsync(new Uri(fileAddress), path); client.Dispose(); } } } Me ajudem por favor, nao sei mais o que fazer
estimado Posted June 3, 2012 at 08:25 AM Report #459959 Posted June 3, 2012 at 08:25 AM (edited) ..... Edited June 3, 2012 at 08:31 AM by estimado Visual Studio 2010 C#
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now