How to get Directory size in IsolatedStorage of Windows Phone 8 App

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.

 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");

你可能感兴趣的:(windows phone)