1
I have a question, I am using Webclient in C#language, I have the following problem: I click on Download a file, and it does not start downloading, it says that downloading is already finished...
Code:
WebClient Web = new WebClient();
string Info = Web.DownloadString("https://drive.google.com/uc?authuser=0&id=1_bujHdC26AyVeFUZc-5UbDV-g8UuGdXS&export=download");
string VAtualizada = Info.Split('\n')[0];
V1 = VAtualizada.Split('.')[0];
V2 = VAtualizada.Split('.')[1];
V3 = VAtualizada.Split('.')[2];
metroLabel2.Text = "Versão mais recente: V" + VAtualizada;
frmGerador.Versao = VAtualizada;
Web.DownloadProgressChanged += new DownloadProgressChangedEventHandler(Web_DownloadProgress);
Web.DownloadFileCompleted += new AsyncCompletedEventHandler(Web_DownloadCompleted);
Web.DownloadFileAsync(new Uri(Info.Split('\n')[1]), Application.StartupPath + @"\Gerador de Deck V" + V1 + "." + V2 + "." + V3 + " - Clash Royale.exe");
Event Downloadfilecompleted:
void Web_DownloadCompleted(object sender, AsyncCompletedEventArgs e)
{
MessageBox.Show("A nova versão foi baixada com sucesso." + Environment.NewLine + "O programa será reiniciado.", "Atualização", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
Can anyone tell me why of the error? And also in the Downloadprogress event I can only get the following information: e.Bytesreceived
Code:
void Web_DownloadProgress(object sender, DownloadProgressChangedEventArgs e)
{
metroLabel5.Text = "Baixado: " + e.BytesReceived / 1024 + "KB";
}
Summarizing my doubts so far: - By clicking Download, the file says: "New version successfully downloaded." without having downloaded. (Before it was normal, now not) - I cannot use the e.Totalbytestoreceive Properties or.Progresspercentageage in the Downloadprogress method
Can anyone help me? Comment below on any questions!
Hello friend! Thanks for the help, I managed to solve! I will explain what was happening. It was all right to download, all right. The problem that occurred that I clicked on downloading, and already said "Downloaded successfully" without having downloaded, was why variables V1, V2 and V3 were strings, was I switch to whole type, which started to download! Already the error that I could not use the properties e.Totalbytestoreceive and neither e.Progresspercentageage, was why I was downloading files through Google Drive (??), I just switched to Mediafire, which worked all right! Tips, comment here;
– Lucas Bittencourt