VistaDB 6
VistaDB / Developer's Guide / How To Perform Common Tasks / Work with Isolated Storage / Calculating free space in isolated storage
In This Topic
    Calculating free space in isolated storage
    In This Topic

    Isolated storage is a unique situation because you may not know in advance how much storage the user is allowed to write in the store. This can lead to out of disk space errors for even small amounts of data if the users quota has other data in the store already.

    The following example is for testing the free space in the isolated storage. Any app that is using isolated storage should be sure to check this periodically because other apps my also be using the store and use up the quota.

    Checking Free Space in Isolated Storage
    Copy Code
    public void CheckIsolatedFreeSpace()
       // Get an isolated store for this assembly and put it into an
       // IsolatedStoreFile object.
       IsolatedStorageFile isoStore = IsolatedStorageFile.GetStore(IsolatedStorageScope.User | IsolatedStorageScope.Assembly, null, null);
       // Use the CurrentSize and MaximumSize methods to find remaining
       // Cast that number into a long type and put it into a variable.
       long spaceLeft = (long)(isoStore.MaximumSize - isoStore.CurrentSize);
       Assert.IsTrue(spaceLeft > 0, "No free storage in the isolated storage.");
    See Also