当前位置: 首页>>代码示例>>C#>>正文


C# IsolatedStorageFile.CleanDirectory方法代码示例

本文整理汇总了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();
                }
            }
        }
开发者ID:l1183479157,项目名称:coreclr,代码行数:63,代码来源:IsolatedStorageFileSmall.cs


注:本文中的System.IO.IsolatedStorage.IsolatedStorageFile.CleanDirectory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。