[System.Security.SecurityCritical] // auto-generated #endif public void Remove() { #if !FEATURE_LEGACYNETCF bool removedAll = true; FileLock groupLock = FileLock.GetFileLock(Path.Combine(IsolatedStorageFile.IsolatedStorageRoot, IsolatedStorageFile.s_LockPathPrefix), IsolatedStorageFile.s_GroupPathPrefix + "-" + m_ObfuscatedId); try { groupLock.Lock(); foreach (string storeDir in Directory.UnsafeGetDirectories(Path.Combine(IsolatedStorageFile.IsolatedStorageRoot, IsolatedStorageFile.s_StorePathPrefix), "*", SearchOption.TopDirectoryOnly)) { string groupFile = Path.Combine(storeDir, IsolatedStorageFile.s_GroupFileName); if (m_ObfuscatedId.Equals(File.UnsafeReadAllText(groupFile))) { IsolatedStorageFile f = IsolatedStorageFile.GetUserStoreFromGroupAndStorePath(Group, storeDir); removedAll = removedAll & f.TryRemove(); } } IsolatedStorageFile.TouchFile(Path.Combine(m_GroupPath, IsolatedStorageFile.s_CleanupFileName)); if (removedAll) { IsolatedStorageAccountingInfo.RemoveAccountingInfo(m_GroupPath); File.UnsafeDelete(Path.Combine(m_GroupPath, IsolatedStorageFile.s_IdFileName)); File.UnsafeDelete(Path.Combine(m_GroupPath, IsolatedStorageFile.s_CleanupFileName)); Directory.UnsafeDelete(m_GroupPath, false); } } catch (IOException) { // There isn't anything we can really do about this. Ignoring these sorts of issues shouldn't lead to corruption. } catch (UnauthorizedAccessException) { // There isn't anything we can really do about this. Ignoring these sorts of issues shouldn't lead to corruption. } finally { groupLock.Unlock(); } #else // !FEATURE_LEGACYNETCF try { using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication()) { isf.Remove(); } } catch (IOException) { // There isn't anything we can really do about this. Ignoring these sorts of issues shouldn't lead to corruption. } catch (UnauthorizedAccessException) { // There isn't anything we can really do about this. Ignoring these sorts of issues shouldn't lead to corruption. } #endif // !FEATURE_LEGACYNETCF }
[System.Security.SecurityCritical] // auto-generated #endif public static IEnumerable <IsolatedStorageGroup> GetGroups() { List <IsolatedStorageGroup> groups = new List <IsolatedStorageGroup>(); #if !FEATURE_LEGACYNETCF try { foreach (string groupDir in Directory.UnsafeGetDirectories(Path.Combine(IsolatedStorageFile.IsolatedStorageRoot, IsolatedStorageFile.s_GroupPathPrefix), "*", SearchOption.TopDirectoryOnly)) { string idFile = Path.Combine(groupDir, IsolatedStorageFile.s_IdFileName); string id; FileLock groupLock = FileLock.GetFileLock(Path.Combine(IsolatedStorageFile.IsolatedStorageRoot, IsolatedStorageFile.s_LockPathPrefix), IsolatedStorageFile.s_GroupPathPrefix + "-" + DirectoryInfo.UnsafeCreateDirectoryInfo(groupDir).Name); try { groupLock.Lock(); if (!File.UnsafeExists(Path.Combine(groupDir, IsolatedStorageFile.s_CleanupFileName))) { id = File.UnsafeReadAllText(idFile); if (IsolatedStorageAccountingInfo.IsAccountingInfoValid(groupDir)) { using (IsolatedStorageAccountingInfo accountingInfo = new IsolatedStorageAccountingInfo(groupDir)) { groups.Add(new IsolatedStorageGroup(id, accountingInfo.Quota, accountingInfo.UsedSize, groupDir)); } } else { // In this case we've tried to deseriaize a group that doesn't have valid data. We'll try to remove it. try { new IsolatedStorageGroup(id, 0, 0, groupDir).Remove(); } catch (Exception) { // We couldn't remove the group for some reason. Ignore it and move on. } } } } catch (IOException) { // There isn't anything we can really do about this. Ignoring these sorts of issues shouldn't lead to corruption. } catch (UnauthorizedAccessException) { // There isn't anything we can really do about this. Ignoring these sorts of issues shouldn't lead to corruption. } finally { groupLock.Unlock(); } } } catch (IOException) { // There isn't anything we can really do about this. Ignoring these sorts of issues shouldn't lead to corruption. } catch (UnauthorizedAccessException) { // There isn't anything we can really do about this. Ignoring these sorts of issues shouldn't lead to corruption. } #else try { using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication()) { groups.Add(new IsolatedStorageGroup(isf.GroupName, Int64.MaxValue, 0, IsolatedStorageFile.IsolatedStorageRoot)); } } catch (IOException) { // There isn't anything we can really do about this. Ignoring these sorts of issues shouldn't lead to corruption. } catch (UnauthorizedAccessException) { // There isn't anything we can really do about this. Ignoring these sorts of issues shouldn't lead to corruption. } catch (IsolatedStorageException) { // There isn't anything we can really do about this. Ignoring these sorts of issues shouldn't lead to corruption. } #endif return(groups); }