How to get the file size of Storage File in Windows phone app

StorageFile class provides different methods with the help of which we can retrieve the file size of a give StorageFile.

 

In the given function below we retrieve the file size of a given StorageFile using GetBasicPropertiesAsync() method. This method returns the basic properties of the given Storagefile in form of class object from which we can get the size of the given StorageFile.

 

 

Note:The property size of basicproperties object returns the file size in Ulong data type.

To convert the ulong type to proper file size in form of Bytes, Kilobytes or MB we have used the CalculateSize helper function.


Chetan Gulati

Currently am doing B TECH in IT from Delhi Technological University. App development is my passion. Believe in quality rather than quantity.

Read more:
How to create your first Windows Phone app
How to change the App name and Tile name of your Windows phone app
Data binding in Windows Phone app – One way binding
Close