Home > OS >  What is the most basic way to download a file to a certain directory in windows from a URL?
What is the most basic way to download a file to a certain directory in windows from a URL?

Time:02-09

I've tried stuff from QT and tried some stuff from github and the code seems to not error but I just do not get where to put the link or file name I want to download and where I want it to be saved at (temporary files %Temp% is where I want it to be). Just wondering if anybody has found an easy way to download files, back in C# all you had to use was a webclient library and it was simple to use and download multiple files.

CodePudding user response:

There is URLDownloadToFile(). You give it a URL and a file path, and it does all of the work for you. Just know that it is also notoriously buggy, and lacks decent error reporting.

Another solution, but requires more work on your part, is to use the WinInet API, such as InternetOpenURL() and InternetReadFile(). You can send a request and then download and use the data however you want, such as writing it to a file. See Downloading Resources from the WWW.

Otherwise, just use a 3rd party client library, such as libcurl or similar.

CodePudding user response:

Alright so after some digging and testing finally found what works best the only issue is specifying environment variables with this method.

Install this using QPM and it works beautifully and all it takes is lines of code in the QML file. Hopefully this helps whoever else has this problem and wants an easy fix.

https://github.com/Larpon/QuickDownload

  •  Tags:  
  • Related