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.
Double click the button to add some code and scroll up till the beginning of your header.
Include <windows.h> like this.
Scroll down a bit and add using namespace System::Net; right here,
Scroll down a bit more and add WebClient(); here..
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.
Double click the button to add some code and scroll up till the beginning of your header.
Include <windows.h> like this.
Scroll down a bit and add using namespace System::Net; right here,
Scroll down a bit more and add WebClient(); here..
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 button for more tutorials!