Forum > Windows
What WinAPI functions can be used to save a file to a folder at a network drive?
440bx:
You're welcome.
Another thing I forgot to mention is documentation.
There is a page for fphttpclient:
https://wiki.freepascal.org/fphttpclient
which does give some information about how to use fphttpclient but, I have not seen a complete list of the methods it provides along with whatever it is they do. IOW, using fphttpclient requires a bit of guesswork, reading examples and reading its implementation. Consequently, there is no documentation when one way (synchronous/asynchronous) or another should be used. e.g, the method Get has 4 overloads and nowhere does it say when or why one of them is preferred over the other.
Contrast that with WinHTTP that has well organized, full documentation. All it takes is reading the documentation to know what is available. Though, in that respect, finding an asynchronous example is not easy (it definitely should be easier.)
The one thing fphttpclient has over WinHTTP is that, if the security dlls it needs are there, it seems quite reliable. Can't says that for WinHTTP which under Win 7 (and likely prior versions) can be next to impossible to get it to work because of configuration problems. Works great on Win 10 though but, not everyone in the world run Win 10 (for good reason too.)
PascalDragon:
--- Quote from: Gustavo 'Gus' Carreno on June 22, 2025, 05:33:33 pm ---So, my main point is: Why not just use FPHHTPClient and a File Stream?
--- End quote ---
Maybe the NAS of the user does not provide a HTTP interface? Maybe using SMB is simply much more transparent and flexible? For example you can simply mount the file system and have it be a transparent part of the file system (be it somewhere in the /-structure of *nix or a drive letter on Windows). Also modifying parts of a file and working with large files is much more simpler (or even possible) with SMB compared to HTTP.
On the Pascal side of things you can also simply use TFileStream in this case (which on Windows encapsulates the mentioned CreateFile and the related APIs).
When working with files in the local network I would always pick SMB instead of HTTP simply due the restrictions of the later and the flexibility of the former.
Navigation
[0] Message Index
[*] Previous page