C
C#2y ago
Nikolaaa

Can not download file on dropbox

I am trying to make a self updater but I can not download files from dropbox
7 Replies
Nikolaaa
Nikolaaa2y ago
private void UpdateWorker_DoWork(object sender, DoWorkEventArgs e)
{
WebClient webClient = new WebClient();
var client = new WebClient();
try
{
System.Threading.Thread.Sleep(5000);
File.Delete(@".\UniverseClient.exe");
client.DownloadFile("https://www.dropbox.com/s/8jlvmbg68hr7ie1/UniverseClient.zip?dl=1", @"UniverseClient.zip");
string zipPath = @".\UniverseClient.zip";
string extractPath = @".\";
ZipFile.ExtractToDirectory(zipPath, extractPath);
File.Delete(@".\UniverseClient.zip");
Process.Start(@".\UniverseClient.exe");
this.Close();
}
catch
{
MessageBox.Show("Could not update the launcher, please download new version from the site or try again.", "Update Interrupted!", MessageBoxButtons.OK, MessageBoxIcon.Error);
Process.Start("UniverseClient.exe");
this.Close();
}
for (int i = 0; i < 100; i++)
{
Thread.Sleep(1000);
UpdateWorker.ReportProgress(i);
}
}
private void UpdateWorker_DoWork(object sender, DoWorkEventArgs e)
{
WebClient webClient = new WebClient();
var client = new WebClient();
try
{
System.Threading.Thread.Sleep(5000);
File.Delete(@".\UniverseClient.exe");
client.DownloadFile("https://www.dropbox.com/s/8jlvmbg68hr7ie1/UniverseClient.zip?dl=1", @"UniverseClient.zip");
string zipPath = @".\UniverseClient.zip";
string extractPath = @".\";
ZipFile.ExtractToDirectory(zipPath, extractPath);
File.Delete(@".\UniverseClient.zip");
Process.Start(@".\UniverseClient.exe");
this.Close();
}
catch
{
MessageBox.Show("Could not update the launcher, please download new version from the site or try again.", "Update Interrupted!", MessageBoxButtons.OK, MessageBoxIcon.Error);
Process.Start("UniverseClient.exe");
this.Close();
}
for (int i = 0; i < 100; i++)
{
Thread.Sleep(1000);
UpdateWorker.ReportProgress(i);
}
}
It always just catches exception
Angius
Angius2y ago
Check what the exception is That might give you a lead
jcotton42
jcotton422y ago
@Nikolaaa Dropbox is not a suitable CDN for application files Use something actually meant for this If your application is open source, GitHub releases are an option
Nikolaaa
Nikolaaa2y ago
is there anything easier to use than github?
jcotton42
jcotton422y ago
Is your project already on GitHub? That is, open source and the code is there Releases are pretty easy imo
Nikolaaa
Nikolaaa2y ago
it isnt but I will install github extension in visual studio and push the repository yea with version control and stuff i will try that