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

posted on 2013-11-25 13:14  明月几时有25  阅读(191)  评论(0编辑  收藏  举报