Hack Forums
[C#] downloading file from url c# - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [C#] downloading file from url c# (/showthread.php?tid=6069728)

Pages: Pages 1 2


downloading file from url c# - notahackerman - Apr 21, 2020

C#, i'm using already this: using System.Net;

the code is:

Code
string www = "https://website.ro/program.exe";
string pathex1 = Environment.ExpandEnvironmentVariables(@"%USERPROFILE%\AppData\Roaming\");
//string pathex2 = @"%USERPROFILE%\AppData\Roaming\";
WebClient webClient = new WebClient();
webClient.DownloadFile(www, pathex1);
//webClient.DownloadFile(www, pathex2);

what's wrong with that code guys?
i tried with both types (ex1,ex2), which one is wrong?

i'm trying to download a .exe to appdata, roaming..

after i open the program , it's closing instant..

anyway, i used this code in "public static void Main()"

i'm waiting your answers, please..


RE: downloading file from url c# - HFDone - Apr 21, 2020

the site may request form data and info to le you download
use https://anonfile.com


RE: downloading file from url c# - Klonopin - Apr 21, 2020

Show the error message, if its not showing an error message it just might be downloading program.exe to (@"%USERPROFILE%\AppData\Roaming\");

But is website.ro/program.exe even a link to a program? so it might just not be able to download anything.


RE: downloading file from url c# - notahackerman - Apr 21, 2020

(Apr 21, 2020 10:22 AM)Klonopin Wrote:  Show theerror message, if its not showing anerror message it just might be downloading program.exe to  (@"%USERPROFILE%\AppData\Roaming\");

But is website.ro/program.exe even a link to a program? so it might just not be able to download anything.

it's silent, i can't see any error message or debug.

that website is an example.

any idea?


RE: downloading file from url c# - NYANxCAT - Apr 21, 2020

(Apr 21, 2020 10:32 AM)notahackerman Wrote:  it's silent, i can't see anyerror message or debug.

that website is an example.

any idea?

First, learn then ask for help.

Tutorial: Learn to debug C# code using Visual Studio
https://docs.microsoft.com/en-us/visualstudio/get-started/csharp/tutorial-debugger?view=vs-2019


RE: downloading file from url c# - notahackerman - Apr 21, 2020

(Apr 21, 2020 11:02 AM)˗ˏˋ NYAN CAT ˎˊ˗ Wrote:  First, learn then ask for help.

Tutorial: Learn to debug C# code using Visual Studio
https://docs.microsoft.com/en-us/visualstudio/get-started/csharp/tutorial-debugger?view=vs-2019

yeah thanks you're very useful, i can google it by myself how to debug but i can't understand why my program is going to close when i open it with that code..


RE: downloading file from url c# - Shadow_Cloud - Apr 21, 2020

(Apr 21, 2020 11:29 AM)notahackerman Wrote:  yeah thanks you're very useful, i can google it by myself how to debug but i can't understand why my program is going to close when i open it with that code..

Have you actually stepped through the code?


RE: downloading file from url c# - notahackerman - Apr 21, 2020

(Apr 21, 2020 11:37 AM)Shadow_Cloud Wrote:  Have you actually stepped through the code?

i think yes, the uploading is working but the downloading results exit from program..


RE: downloading file from url c# - Shadow_Cloud - Apr 21, 2020

(Apr 21, 2020 11:43 AM)notahackerman Wrote:  i think yes, the uploading is working but the downloading results exit from program..

On which line exactly, is it exiting?


RE: downloading file from url c# - notahackerman - Apr 21, 2020

(Apr 21, 2020 11:46 AM)Shadow_Cloud Wrote:  On which line exactly, is it exiting?

both brother


RE: downloading file from url c# - Shadow_Cloud - Apr 21, 2020

(Apr 21, 2020 02:16 PM)notahackerman Wrote:  both brother

Its quite obvious that you have no idea what you are doing here...

https://docs.microsoft.com/en-us/visualstudio/get-started/csharp/tutorial-debugger?view=vs-2019

Go read this.


RE: downloading file from url c# - Accord - Apr 21, 2020

(Apr 21, 2020 11:29 AM)notahackerman Wrote:  yeah thanks you're very useful, i can google it by myself how to debug but i can't understand why my program is going to close when i open it with that code..

Do you even read the link or nah?


RE: downloading file from url c# - notahackerman - Apr 22, 2020

(Apr 21, 2020 11:09 PM)Accord Wrote:  Do you even read the link or nah?

yeah but i don't want to debug, i just wanna something which is working lmao


RE: downloading file from url c# - Accord - Apr 22, 2020

(Apr 22, 2020 12:39 AM)notahackerman Wrote:  yeah but i don't want to debug, i just wanna something which is working lmao

If it doesnt work then debug, thats all you gotta do man


RE: downloading file from url c# - notahackerman - Apr 22, 2020

(Apr 21, 2020 11:02 AM)NYANxCAT Wrote:  First, learn then ask for help.

Tutorial: Learn to debug C# code using Visual Studio
https://docs.microsoft.com/en-us/visualstudio/get-started/csharp/tutorial-debugger?view=vs-2019

(Apr 21, 2020 11:37 AM)Shadow_Cloud Wrote:  Have you actually stepped through the code?

(Apr 21, 2020 11:09 PM)Accord Wrote:  Do you even read the link or nah?

System.Net.WebException: 'An exception occurred during a WebClient request.'
DirectoryNotFoundException: Could not find a part of the path 'C:\Users\xxxxxxxx\AppData\Roaming\'.

i debugged it, that's it.. anyway the path it's working so what's wrong?