Grab URL from net to file - Printable Version +- QB64 Phoenix Edition (https://qb64phoenix.com/forum) +-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1) +--- Forum: Code and Stuff (https://qb64phoenix.com/forum/forumdisplay.php?fid=3) +---- Forum: Programs (https://qb64phoenix.com/forum/forumdisplay.php?fid=7) +---- Thread: Grab URL from net to file (/showthread.php?tid=2146) |
Grab URL from net to file - eoredson - 11-07-2023 I recently posted a question about grabbing a url and wrote the following: This attempts to grab a url and writes it to a filename: Code: (Select All) Rem program to grab url filename. RE: Grab URL from net to file - SpriggsySpriggs - 11-07-2023 I wouldn't recommend changing the title of the QB64 program in your download loop like that. Windows is not a huge fan of how QB64 changes the title and excessive title changes can cause issues. RE: Grab URL from net to file - SMcNeill - 11-07-2023 One thing you need to watch out for is corrupting your data file. Open Urlfile$ For Binary As #filehandle <-- This is where you open your file. Before that line, add this one: Open Urlfile$ For OUTPUT As #filehandle: CLOSE #filehandle As it exists, you could have the file already on the drive (lets say at 100,000 bytes of data), and then you choose not to erase it. When you download the new version of the file, it's only 96,000 bytes in size -- so it'll overwrite those first 96,000 bytes and then leave the rest unchanged. You need to blank that file before writing to it, or else you're just asking for trouble in the future with left over data. RE: Grab URL from net to file - SpriggsySpriggs - 11-07-2023 (11-07-2023, 03:12 PM)SMcNeill Wrote: One thing you need to watch out for is corrupting your data file. Oh, yeah. In my opinion, I'd just check if the file exists first then prompt to either kill it and proceed or just not download it. Or, you could even go as far as to make it autoincrement the name so you don't have naming conflicts. Like "file1.jpg(1)" "file1.jpg(2)" and so on and so forth. RE: Grab URL from net to file - eoredson - 11-08-2023 Quote:Oh, yeah. In my opinion, I'd just check if the file exists first then prompt to either kill it and proceed or just not download it.It already does.. btw: If you don't like the timed _Title then just Rem it out.. RE: Grab URL from net to file - SpriggsySpriggs - 11-10-2023 (11-08-2023, 12:11 AM)eoredson Wrote:Quote:Oh, yeah. In my opinion, I'd just check if the file exists first then prompt to either kill it and proceed or just not download it.It already does.. Eric, I was talking to Steve about the killing of the file when he was suggesting how to handle it already existing. As for the "timed _Title", it isn't a matter of me not liking it. I was saying Windows doesn't like having the title changed like that. But, uh, yeah, have fun. |