void _folderManagerService_DirListCompleted(object sender, DirListCompletedEventArgs e)
 {
     if (e.Error == null)
     {
         if (e.Result.ErrorCode == WebResult.ErrorCodeList.SUCCESS)
         {
             var dirs = e.Result.Value;
             Folders.Clear();
             KeyValuePair<string, ObservableCollection<FolderDefinition>> folderContainer = new KeyValuePair<string, ObservableCollection<FolderDefinition>>("~", new ObservableCollection<FolderDefinition>());
             Folders.Add(folderContainer);
             foreach (string dirName in e.Result.Value)
             {
                 FolderDefinition folder = new FolderDefinition(dirName);
                 folder.Owner = Locator.LoginPageViewModel.User;
                 folder.UpdateFileList.Execute(null);
                 folderContainer.Value.Add(folder);
             }
             RaisePropertyChange("Folders");
             _folderManagerService.GetSharingAsync(Locator.LoginPageViewModel.User.id);
         }
         Locator.LoggerViewModel.AddLog("Get folder list: " + e.Result.ErrorCode);
     }
 }
 void _folderManagerService_GetSharingCompleted(object sender, GetSharingCompletedEventArgs e)
 {
     if (e.Error == null)
     {
         if (e.Result.ErrorCode == WebResult.ErrorCodeList.SUCCESS)
         {
             foreach (Sharing share in e.Result.Value)
             {
                 KeyValuePair<string, ObservableCollection<FolderDefinition>> folderContainer;
                 folderContainer = (from f in Folders where f.Key == share.user select f).SingleOrDefault();
                 if (folderContainer.Key == null && folderContainer.Value == null)
                 {
                     folderContainer = new KeyValuePair<string, ObservableCollection<FolderDefinition>>(share.user, new ObservableCollection<FolderDefinition>());
                     Folders.Add(folderContainer);
                 }
                 FolderDefinition fd = new FolderDefinition(share.folder)
                 {
                     Owner = new ServiceReference.User()
                     {
                         id = share.idOwner,
                         username = share.user,
                     }
                 };
                 folderContainer.Value.Add(fd);
                 fd.UpdateFileList.Execute(null);
             }
             RaisePropertyChange("Folders");
         }
         Locator.LoggerViewModel.AddLog("Get sharing directory: " + e.Result.ErrorCode);
     }
 }
        private void DeleteDirectoryBody(FolderDefinition folderDefinition)
        {
            foreach (KeyValuePair<string, ObservableCollection<FolderDefinition>> uf in Folders)
            {
                if (uf.Value.Contains(folderDefinition))
                {
                    if (uf.Key == "~")
                    {
                        uf.Value.Remove(folderDefinition);
                        RaisePropertyChange("Folders");
                        _folderManagerService.DeleteAsync(Locator.LoginPageViewModel.User.id, folderDefinition.Name);
                    }
                }

            }
        }