When creating a file with zero size, I would like to set the logical size of the file to be bigger than zero size.
One drive shows for dehydrated files Size on disk with zero bytes and the Size
it will be shown to a value that is the bigger than zero.
Can this behavior be done through windows api functions?
Thanks.
Sample onedrive properties window for a file:
Asked
Active
Viewed 360 times
0

Iulian Rotaru
- 72
- 2
-
2https://learn.microsoft.com/en-us/windows/win32/fileio/sparse-files – Jonathan Potter Sep 18 '19 at 14:37
-
Making the file as sparse and moving the file pointer to the desired size will set the Size on Disk to the desired size and not the size. an example how to create sparse files can be found here: [link](https://stackoverflow.com/questions/4011508/how-to-create-a-sparse-file-on-ntfs) So the question still remains how to make the windows show the Size value in properties and Size on Disk to be zero . @JonathanPotter thanks for the quick answer. – Iulian Rotaru Sep 19 '19 at 07:28
-
For a OneDrive file, Size-on-disk is zero is possible because to help users save local storage, OneDrive can only store the file on Cloud. When you need to access the file then download it. Size is the actual size of the file in bytes. Why do you want to fake a size for an actual zero-size file? – Rita Han Sep 20 '19 at 03:25