Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27472

download string works, download file doesn't

$
0
0
I'm working within my public dropbox, and using the default debug folder for testing for this, so I apologize if it's a user error, permissions, or something associated with that... Since I can correctly get a line from a text file inside the public folder, I figure I should be able to correctly download a file out of it too.

**Yes, I have blanked out my url's even though they are public, should be safer. I can provide if absolutely necessary.

This gets the correct string in my text file.
Code:

using (WebClient wc = new WebClient())
                string txt = wc.DownloadString("http://dl.dropbox.com/u/****/****.txt");

Here I set programpath to the path where the program was executed from, and download the new file to that path. It replaces the filename at the end, with the new filename I want to save it as.
Code:

programpath = System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase;
            programpath = programpath.Substring(0, programpath.LastIndexOf("/")+1);
using (WebClient webClient = new WebClient())
            {
                webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(ProgressChanged);
                webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(Completed);
                webClient.DownloadFileAsync(new Uri("http://dl.dropbox.com/u/****/****.exe"), System.IO.Path.Combine(programpath, "****.Exe"));
            }

I have correctly added the event handlers, and upon debugging, the ProgressChanged event never fires, and the FileCompleted event does fire, but I don't have a file in the current debug folder.

Edit - I should add that clicking the url in visual studio (the DownloadFile one) launches the browser inside of visual studio and starts a download like IE would...

Viewing all articles
Browse latest Browse all 27472

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>