本文整理汇总了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();
}
}
}