Free disk space on a network drive in Delphi-Collection of common programming errors

I am making a program for A2 Computing which exports a lot of data. My HDD allocation on the local network is about 50 MB, so it’s a good candidate to test the “no disk space” error.

Currently when the program runs out of space it crashes mid-export with I/O Error 112. I would like to warn ahead of time if the file might exceed available space. I know how big the file will be (24.8 bytes per record, on average), so all I need to do is find out how much space is free.

As I am working on a network drive, with a file path like \\qmcsan1\Cxxxxx$\filename.csv, how do I use functions like DiskFree to calculate available space? Any such function also needs to handle local drives like C:/.

Any ideas much appreciated.