Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Tutorial How to download a file in C++
#1
Hey OMA 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]

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]

Scroll down a bit and add using namespace System::Net; right here,
[Image: XnkwmJaVFH.png]

Scroll down a bit more and add WebClient(); here..
[Image: O1iQvC4M8H.png]

Now you're done with including the libraries and initializing stuff. Let's add a download code to our button!

C++ Code
  1. private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
  2.  
  3. try
  4. {
  5. WebClient^ downloadclient = gcnew WebClient;
  6. MessageBox::Show("Starting download..");
  7. downloadclient->DownloadFile("http://www.mysite.com/mystuff/myapp.exe","myapp.exe");
  8. MessageBox::Show("Download finished!");
  9.  
  10. }
  11. catch ( WebException^ webEx )
  12. {
  13. MessageBox::Show("Download failed!");
  14.  
  15. }
  16. }


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] button for more tutorials!

[Image: lQDUjba.jpg]
Reply

#2
[Image: O1iQvC4M8H.png]
It hurts me when people fuck up spaces/tabs like that..
[Image: MaEIQ.png]
Reply

#3
hahha yes the same @Pozzuh , hmmm seems like in C++ instead the point it puts :: , in C# is point, arrg im confused
Reply

#4
The same for Java please !
Reply



Possibly Related Threads…
Thread Author Replies Views Last Post
  [Request] download link server exe for addon lander 2 2,982 08-01-2013, 19:57
Last Post: lander
  download mw3 dedicated server clacki 1 4,776 07-21-2013, 15:51
Last Post: DidUknowiPwn
Wink Preview Black ops 2 - CFG file dump SLiiTH3R 11 19,929 06-09-2013, 16:01
Last Post: dylankrajewski
  [Release] Modern Warfare 3 Fast File Sounds master131 5 18,377 05-21-2013, 16:46
Last Post: ZURA.
Question Help change single file lzma maker to multiple in c# raminr63 1 3,071 05-12-2013, 19:31
Last Post: raminr63
Wink [News] Call of Duty Online (CN) Enters BravoTest (client is avaliable for download kjkszpj 17 11,472 05-06-2013, 02:18
Last Post: logitechnoob
  download d3d9.dll odok 1 6,793 04-28-2013, 11:10
Last Post: hillbilly
  [Release] Black Ops II Fast File Explorer master131 19 26,933 03-28-2013, 16:16
Last Post: kokole
  i want change mod to .iwd file ABDULMAILK 7 6,296 03-10-2013, 05:24
Last Post: DidUknowiPwn
  Download C/C#/C++ programming e-books - Learning C would be fun KrypTiK 4 4,063 01-03-2013, 14:36
Last Post: alvarogt95

Forum Jump:


Users browsing this thread:
1 Guest(s)

Forum Powered By MyBB, Theme by © 2002-2024 Melroy van den Berg.