Click here to Skip to main content
15,890,845 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I wanted to know Local Folder Size.?(e.g. 210 MB)

for e.g. I have an application which would download some of the content into my local folder and I want to check the size of my local folder how much MB of GB is there.



How I could get it. in windows 8.1..?



I have tried with MSDN and google also but there is no clue.





Thank you,

-Jitendra Jadav.
Posted

You have to use a recursive method that calculate the size of each file from the current folder and invoke the same method for each subfolder.

In this method to find the sub-items of the current folder you should use Directory.GetDirectories() method, and to find the size of a file you can use FileInfo class (both classes are from System.IO namespace).
 
Share this answer
 
Use this method to get all file names: http://msdn.microsoft.com/en-us/library/ms143316%28v=vs.110%29.aspx[^].

You don't need to use recursion by yourself; this method allows you to get all files in the directory. Use SearchOption.AllDirectories:
http://msdn.microsoft.com/en-us/library/ms143448%28v=vs.110%29.aspx[^].

The size you need will be the sum of the sizes of all files. This is how you can get the size for each file:
http://msdn.microsoft.com/en-us/library/system.io.fileinfo.length%28v=vs.110%29.aspx[^],
http://msdn.microsoft.com/en-us/library/System.IO.FileInfo%28v=vs.110%29.aspx[^].

—SA
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900