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.
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