本文整理匯總了C#中System.IO.IsolatedStorage.IsolatedStorageFile.CleanDirectory方法的典型用法代碼示例。如果您正苦於以下問題:C# IsolatedStorageFile.CleanDirectory方法的具體用法?C# IsolatedStorageFile.CleanDirectory怎麽用?C# IsolatedStorageFile.CleanDirectory使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.IO.IsolatedStorage.IsolatedStorageFile
的用法示例。
在下文中一共展示了IsolatedStorageFile.CleanDirectory方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: FetchOrCreateStore
[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();
}
}
}