Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

C# 

downloading file from url c#

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..
the site may request form data and info to le you download
use https://anonfile.com
[Image: bitcoin.png] Be Nice For Once 15hVUVz7xA4kazHdk2BuErENGCskVwjYXP
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.

looking for work
(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?
(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/visuals...ew=vs-2019
(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/visuals...ew=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..
(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?
(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..
(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?
(Apr 21, 2020 11:46 AM)Shadow_Cloud Wrote:  On which line exactly, is it exiting?

both brother
(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/visuals...ew=vs-2019

Go read this.
(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?
(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
(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
(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/visuals...ew=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?


Possibly Related Threads...
Thread / Author Replies Views Last Post
[C] by ConcentratedNagaJan 18, 2021 10:51 PM 0 154 Jan 18, 2021 10:51 PM
Last Post: ConcentratedNaga
[.NET] by TerminallyIllDec 24, 2018 09:17 AM 5 194 Dec 24, 2018 09:17 AM
Last Post: CreatedAutomated
[.NET] by RoSESPApr 26, 2018 08:27 AM 3 187 Apr 26, 2018 08:27 AM
Last Post: RoSESP