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

上一篇:【lintcode】 二分法总结 I


下一篇:BZOJ 3224 - 普通平衡树 - [Treap][Splay]