c# - Download file and automatically save it to folder -


i'm trying make ui downloading files site. site have zip-files , these need downloaded directory entered user. however, can't succeed download file, opens temporary folder.

code:

private void webbrowser1_navigating(object sender, webbrowsernavigatingeventargs e) {         e.cancel = true;         string filepath = null;             filepath = textbox1.text;             webclient client = new webclient();             client.downloadfilecompleted += new asynccompletedeventhandler(client_downloadfilecompleted);             client.downloadfileasync(e.url, filepath); } 

full sourcecode: http://en.paidpaste.com/lqemiq

why not bypass webclient's file handling pieces altogether. perhaps similar this:

    private void webbrowser1_navigating(object sender, webbrowsernavigatingeventargs e)     {         e.cancel = true;         webclient client = new webclient();          client.downloaddatacompleted += new downloaddatacompletedeventhandler(client_downloaddatacompleted);          client.downloaddataasync(e.url);     }      void client_downloaddatacompleted(object sender, downloaddatacompletedeventargs e)     {         string filepath = textbox1.text;         file.writeallbytes(filepath, e.result);         messagebox.show("file downloaded");     } 

Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -