System.IO.IsolatedStorage.Helper.GetRootDirectory C# (CSharp) Méthode

GetRootDirectory() static private méthode

The full root directory is the relevant special folder from Environment.GetFolderPath() plus "IsolatedStorage" and a set of random directory names if not roaming. Examples: User: @"C:\Users\jerem\AppData\Local\IsolatedStorage\10v31ho4.bo2\eeolfu22.f2w\" User|Roaming: @"C:\Users\jerem\AppData\Roaming\IsolatedStorage\" Machine: @"C:\ProgramData\IsolatedStorage\nin03cyc.wr0\o3j0urs3.0sn\" Identity for the current store gets tacked on after this.
static private GetRootDirectory ( IsolatedStorageScope scope ) : string
scope IsolatedStorageScope
Résultat string
        internal static string GetRootDirectory(IsolatedStorageScope scope)
        {
            if (IsRoaming(scope))
            {
                if (string.IsNullOrEmpty(s_roamingUserRootDirectory))
                {
                    s_roamingUserRootDirectory = GetDataDirectory(scope);
                }
                return s_roamingUserRootDirectory;
            }

            if (IsMachine(scope))
            {
                if (string.IsNullOrEmpty(s_machineRootDirectory))
                {
                    s_machineRootDirectory = GetRandomDirectory(GetDataDirectory(scope), scope);
                }
                return s_machineRootDirectory;
            }

            if (string.IsNullOrEmpty(s_userRootDirectory))
                s_userRootDirectory = GetRandomDirectory(GetDataDirectory(scope), scope);

            return s_userRootDirectory;
        }

Usage Example

        // https://github.com/dotnet/corefx/issues/10935
        // Evidence isn't currently available
        // public static IsolatedStorageFile GetStore(IsolatedStorageScope scope, Evidence domainEvidence, Type domainEvidenceType, Evidence assemblyEvidence, Type assemblyEvidenceType) { return default(IsolatedStorageFile); }

        private void Initialize(IsolatedStorageScope scope)
        {
            // InitStore will set up the IdentityHash
            InitStore(scope, null, null);

            StringBuilder sb = new StringBuilder(Helper.GetRootDirectory(scope));

            sb.Append(SeparatorExternal);
            sb.Append(IdentityHash);
            sb.Append(SeparatorExternal);

            if (Helper.IsApplication(scope))
            {
                sb.Append(s_appFiles);
            }
            else if (Helper.IsDomain(scope))
            {
                sb.Append(s_files);
            }
            else
            {
                sb.Append(s_assemFiles);
            }
            sb.Append(SeparatorExternal);

            _rootDirectory = sb.ToString();
            Helper.CreateDirectory(_rootDirectory, scope);
        }
All Usage Examples Of System.IO.IsolatedStorage.Helper::GetRootDirectory