Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check logical and physical file size on disk using C# file API

Tags:

c#

How to read the logical and physical file size using C# api.

enter image description here

like image 383
Anil Namde Avatar asked Nov 04 '22 22:11

Anil Namde


1 Answers

(new FileInfo(path).Length)

is the actual size. As for size on disk, I don't think there's an API to get it, but you can get it using the actual size, and the cluster size.

There's some info on the calculation required here: http://social.msdn.microsoft.com/Forums/en-US/Vsexpressvcs/thread/85bf76ac-a254-41d4-a3d7-e7803c8d9bc3

like image 164
Gal Avatar answered Nov 14 '22 05:11

Gal