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

GetDataDirectory() static private méthode

static private GetDataDirectory ( IsolatedStorageScope scope ) : string
scope IsolatedStorageScope
Résultat string
        internal static string GetDataDirectory(IsolatedStorageScope scope)
        {
            // This is the relevant special folder for the given scope plus "IsolatedStorage".
            // It is meant to replicate the behavior of the VM ComIsolatedStorage::GetRootDir().

            // (note that Silverlight used "CoreIsolatedStorage" for a directory name and did not support machine scope)

            string dataDirectory = null;

            if (IsMachine(scope))
            {
                // SpecialFolder.CommonApplicationData -> C:\ProgramData
                dataDirectory = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
                    dataDirectory = @"/usr/local/share";
            }
            else if (IsRoaming(scope))
            {
                // SpecialFolder.ApplicationData -> C:\Users\Joe\AppData\Roaming
                dataDirectory = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
            }
            else
            {
                // SpecialFolder.LocalApplicationData -> C:\Users\Joe\AppData\Local
                dataDirectory = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
            }

            dataDirectory = Path.Combine(dataDirectory, IsolatedStorageDirectoryName);

            return dataDirectory;
        }

Usage Example

Exemple #1
0
        static TestHelper()
        {
            s_rootDirectoryProperty = typeof(IsolatedStorageFile).GetProperty("RootDirectory", BindingFlags.NonPublic | BindingFlags.Instance);

            s_roots = new List <string>();

            string hash;
            object identity;

            Helper.GetDefaultIdentityAndHash(out identity, out hash, '.');

            string userRoot       = Helper.GetDataDirectory(IsolatedStorageScope.User);
            string randomUserRoot = Helper.GetRandomDirectory(userRoot, IsolatedStorageScope.User);

            s_roots.Add(Path.Combine(randomUserRoot, hash));

            // Application scope doesn't go under a random dir
            s_roots.Add(Path.Combine(userRoot, hash));

            // https://github.com/dotnet/runtime/issues/2092
            // https://github.com/dotnet/runtime/issues/21742
            if (OperatingSystem.IsWindows() &&
                !PlatformDetection.IsInAppContainer)
            {
                s_roots.Add(Helper.GetDataDirectory(IsolatedStorageScope.Machine));
            }

            // We don't expose Roaming yet
            // Helper.GetDataDirectory(IsolatedStorageScope.Roaming);
        }
All Usage Examples Of System.IO.IsolatedStorage.Helper::GetDataDirectory