Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.
How to check for available storage space on Windows Phone
This code snippet shows how to check whether a Windows Phone app has enough space to store its data using IsolatedStorageFile.
Tip: While IsolatedStorageFile works in Windows Phone 7 and 8, if you're focussing on Windows Phone 8 only you should use the new API - see Quickstart: Working with files and folders in Windows Phone 8
Applications that write data to permanent storage can potentially fail due to out of (storage) memory errors. A well designed application should check for space before writing.
public void CheckDiskSpace(long neededSpace)
using (IsolatedStorageFile myISFile = IsolatedStorageFile.GetUserStoreForApplication())
if (myISFile.AvailableFreeSpace < neededSpace) // if true, means there is no space available in the phone.
throw new Exception("No space available on the phone, please delete a file");
This question originated in the discussion boards: Handle low storage space condition