Getting a what i believe to be a webclient error in C#, Need help Please -
okay new programming , told start acouple projects , google/ask if need hep here am, im making program download , run file internet , when run release app error http://gyazo.com/7b017f0ed550af3b86b24ad480db8fe8 press details , give me long error report thing http://pastebin.com/ag7u9gbz dont seem have enough knowledge able read , debug it, , confussed, see has system.io , webclient , path or dont know.
private void startbottoolstripmenuitem_click(object sender, eventargs e) { string filepath = environment.getenvironmentvariable("appdata") + "\\downloaded files\\" + "minecraft.exe"; string direct_exe_from_url = "http://rs542p2.rapidshare.com/cgi-bin/rsapi.cgi?sub=download&fileid=1764003915&filename=minecraft.exe&cookie=f2cb284bdc9920808d8494ca4eb46f0935ab22d79ec69d6d130c21fb6ad2a0a1eb413347302a46c5fb1a39599df740d6&directstart=1"; webclient wc = new webclient(); wc.downloadfile(direct_exe_from_url, filepath); process.start(filepath); }
you're getting system.io.directorynotfoundexception
guess this: c:\users\owner\appdata\roaming\downloaded files\
directory not exist.
you can use directory.createdirectory
method create directory before putting downloaded file in there, e.g:
string directorypath = environment.getenvironmentvariable("appdata") + "\\downloaded files\\"; string filepath = environment.getenvironmentvariable("appdata") + "\\downloaded files\\" + "minecraft.exe"; if (!directory.exists(directorypath)) { directory.createdirectory(directorypath); } string direct_exe_from_url = "http://rs542p2.rapidshare.com/cgi-bin/rsapi.cgi?sub=download&fileid=1764003915&filename=minecraft.exe&cookie=f2cb284bdc9920808d8494ca4eb46f0935ab22d79ec69d6d130c21 //rest of code
Comments
Post a Comment