[System.Security.SecurityCritical] // auto-generated #endif private static string FetchOrCreateStore(string groupName, string storeName, IsolatedStorageFile isf) { string groupRootPath = GetGroupPathFromName(groupName); string obfuscatedStoreName = GetHash(storeName); string obfuscatedGroupName = GetHash(groupName); string storeRootPath = Path.Combine(IsolatedStorageRoot, Path.Combine(s_StorePathPrefix, obfuscatedStoreName)); FileLock rootLock = FileLock.GetFileLock(IsolatedStorageRoot); try { rootLock.Lock(); if(Directory.UnsafeExists(storeRootPath)) { if (!File.UnsafeExists(Path.Combine(storeRootPath, s_IdFileName))) { File.UnsafeWriteAllText(Path.Combine(storeRootPath, s_IdFileName), storeName); } else { if (!storeName.Equals(File.UnsafeReadAllText(Path.Combine(storeRootPath, s_IdFileName)))) { throw new IsolatedStorageException(Environment.GetResourceString("IsolatedStorage_Init")); } } File.UnsafeWriteAllText(Path.Combine(storeRootPath, s_GroupFileName), obfuscatedGroupName); if (!Directory.UnsafeExists(Path.Combine(storeRootPath, s_FilesPathPrefix))) { Directory.UnsafeCreateDirectory(Path.Combine(storeRootPath, s_FilesPathPrefix)); } if(File.UnsafeExists(Path.Combine(storeRootPath, s_CleanupFileName))) { bool removedAll = isf.CleanDirectory(Path.Combine(storeRootPath, s_FilesPathPrefix)); if(removedAll) { File.UnsafeDelete(Path.Combine(storeRootPath, s_CleanupFileName)); return storeRootPath; } else { throw new IsolatedStorageException(Environment.GetResourceString("IsolatedStorage_Init")); } } else { return storeRootPath; } } else { isf.Reserve(s_DirSize); Directory.UnsafeCreateDirectory(storeRootPath); TouchFile(Path.Combine(storeRootPath, s_CleanupFileName)); Directory.UnsafeCreateDirectory(Path.Combine(storeRootPath, s_FilesPathPrefix)); File.UnsafeWriteAllText(Path.Combine(storeRootPath, s_GroupFileName), obfuscatedGroupName); File.UnsafeWriteAllText(Path.Combine(storeRootPath, s_IdFileName), storeName); File.UnsafeDelete(Path.Combine(storeRootPath, s_CleanupFileName)); return storeRootPath; } } catch(IOException e) { throw GetIsolatedStorageException("IsolatedStorage_Init", e); } catch (UnauthorizedAccessException e) { throw GetIsolatedStorageException("IsolatedStorage_Init", e); } finally { if(rootLock != null) { rootLock.Unlock(); } } }