bmit
bmit

Reputation: 61

Windows Phone - IsolatedStorage - get directory size

How can I get Directory size in IsolatedStorage?

Upvotes: 1

Views: 2020

Answers (1)

Kevin Gosse
Kevin Gosse

Reputation: 39007

There is no API to get the total size of a specific directory in the isolated storage. Therefore, the only alternative you have is to browse the files and manually compute the total size.

Edit: Here is a sample implementation:

long total = 0;

using (var isolatedStorage = IsolatedStorageFile.GetUserStoreForApplication())
{
    string folder = "folder/";

    foreach (var fileName in isolatedStorage.GetFileNames(folder))
    {
        using (var file = isolatedStorage.OpenFile(folder + fileName, FileMode.Open))
        {
            total += file.Length;
        }
    }
}

MessageBox.Show(total + " bytes");

Upvotes: 10

Related Questions