Sparse files in NTFS
This way you can create gigantic files, consisting of zeros, but on the disk they can occupy only a few kilobytes. Real disk space is allocated when some other data is written instead of 0x00. Sparseness will help save disk space only in files that have really large empty areas.
I will demonstrate working with sparse files using the fsutil system utility on the command line.
Using the utility, create an empty large file:
fsutil file createnew test.nul 10000000000Assign the “sparse” attribute to the file:
fsutil sparse setflag test.nulThe attribute itself does not yet save disk space. You also need to mark the area inside the file that will be freed. We have the entire file empty, so the area can be set to the file size.
fsutil sparse setrange test.nul 0 10000000000Done. We look at the result.

You can see how to do these operations in your programs using the API functions in the source code of a small utility that I wrote in 2006. It is also a console, and also like fsutil can assign the sparse attribute and set the range of the freed area. In addition, my program can search for empty areas in a file larger than a certain specified size and free them. There is no need to calculate the offsets yourself.
References: