Hey
s,
today I'm going to show you how to download a file in C++.
You're going to open VC++, press New project and choose Windows Forms Application.
Make some GUI and go to your code.
![[Image: YamSG0iPrp.png]](http://i.nowfollow.nl/YamSG0iPrp.png)
Double click the button to add some code and scroll up till the beginning of your header.
Include <windows.h> like this.
![[Image: yxJXmxGxo8.png]](http://i.nowfollow.nl/yxJXmxGxo8.png)
Scroll down a bit and add using namespace System::Net; right here,
![[Image: XnkwmJaVFH.png]](http://i.nowfollow.nl/XnkwmJaVFH.png)
Scroll down a bit more and add WebClient(); here..
![[Image: O1iQvC4M8H.png]](http://i.nowfollow.nl/O1iQvC4M8H.png)
Now you're done with including the libraries and initializing stuff. Let's add a download code to our button!
And you're basically done! Replace the DownloadFile("http://www.mysite.com/mystuff/myapp.exe","myapp.exe");
with your link and name of the file, and watch how it downloads!
Press that
button for more tutorials!

today I'm going to show you how to download a file in C++.
You're going to open VC++, press New project and choose Windows Forms Application.
Make some GUI and go to your code.
![[Image: YamSG0iPrp.png]](http://i.nowfollow.nl/YamSG0iPrp.png)
Double click the button to add some code and scroll up till the beginning of your header.
Include <windows.h> like this.
![[Image: yxJXmxGxo8.png]](http://i.nowfollow.nl/yxJXmxGxo8.png)
Scroll down a bit and add using namespace System::Net; right here,
![[Image: XnkwmJaVFH.png]](http://i.nowfollow.nl/XnkwmJaVFH.png)
Scroll down a bit more and add WebClient(); here..
![[Image: O1iQvC4M8H.png]](http://i.nowfollow.nl/O1iQvC4M8H.png)
Now you're done with including the libraries and initializing stuff. Let's add a download code to our button!
C++ Code
- private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
-
- try
- {
- WebClient^ downloadclient = gcnew WebClient;
- MessageBox::Show("Starting download..");
- downloadclient->DownloadFile("http://www.mysite.com/mystuff/myapp.exe","myapp.exe");
- MessageBox::Show("Download finished!");
-
- }
- catch ( WebException^ webEx )
- {
- MessageBox::Show("Download failed!");
-
- }
- }
And you're basically done! Replace the DownloadFile("http://www.mysite.com/mystuff/myapp.exe","myapp.exe");
with your link and name of the file, and watch how it downloads!
Press that
![[Image: postbit_reputation.gif]](https://www.itsmods.com/forum/images/twilight/english/postbit_reputation.gif)
![[Image: lQDUjba.jpg]](http://i.imgur.com/lQDUjba.jpg)