Does anyone know how to download a file (without opening a webpage), and save it to a directory in Visual Basic 6.0?
相关问题
- How to download and run a .exe file c#
- Convert VB's Val to Java?
- Invalid Picture In Visual basic 6
- Compile is really slow for a solution with many pr
- vb6 Open File For Append issue Path Not Found
相关文章
- Reading (with Filesystem.FileGet) VB6 record file
- Trim all types of whitespace, including tabs
- how to programmatically download a public Google D
- How to destroy an object
- Downloading in background and waking app when fini
- How to prepend a header in a text file
- VB6 — using POST & GET from URL and displaying in
- Using a VB6.dll in .Net
You need to use the Internet Transfer control, see http://www.vb-helper.com/howto_get_file_from_web.html for a sample. If you need to specify credentials, check out http://support.microsoft.com/kb/173264 as well.
I would suggest using the Internet Transfer Control
I don't like the Internet Transfer Control because it is synchronous. Once you start a download your application is unresponsive until the file is downloaded or an error is thrown. There are plenty of good examples of using the WININET DLL to write asynchronous methods. It is not trivial, but it is also very do-able. Here is an example from stackoverflow.
If you want to do it with code only (no Internet Transfer Control), VBNet.mvps.org has a really good how-to article that uses the URLDownloadToFile API call.
From the article:
FYI - in testing on Windows 7, it would only return the cached version, so I had to use the extra function mentioned in the article to clear it first (and that worked).
Then just call the above function with the destination URL first, to clear the cache.
Try This:
You must give it a filename in the what to save it as:
Example:
You don't need API calls, you don't need the Internet Transfer control. Just do it the easy way, using native VB6 code. Here's an excellent article by Karl Peterson with sample code.