System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForDomain C# (CSharp) Method

GetUserStoreForDomain() public static method

public static GetUserStoreForDomain ( ) : IsolatedStorageFile
return IsolatedStorageFile
        public static IsolatedStorageFile GetUserStoreForDomain()
        {
            return GetStore(IsolatedStorageScope.Assembly | IsolatedStorageScope.Domain | IsolatedStorageScope.User);
        }

Same methods

IsolatedStorageFile::GetUserStoreForDomain ( ) : System.IO.IsolatedStorage.IsolatedStorageFile

Usage Example

Esempio n. 1
0
        // If IsolatedStorageFile is null, then we default to using a file that is scoped by user, appdomain, and assembly.
        private static InitialiationData InitializeFileStream(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize, IsolatedStorageFile?isf)
        {
            if (path == null)
            {
                throw new ArgumentNullException(nameof(path));
            }

            if ((path.Length == 0) || path.Equals(BackSlash))
            {
                throw new ArgumentException(
                          SR.IsolatedStorage_Path);
            }

            bool createdStore = false;

            if (isf == null)
            {
                isf          = IsolatedStorageFile.GetUserStoreForDomain();
                createdStore = true;
            }

            if (isf.Disposed)
            {
                throw new ObjectDisposedException(null, SR.IsolatedStorage_StoreNotOpen);
            }

            switch (mode)
            {
            case FileMode.CreateNew:            // Assume new file
            case FileMode.Create:               // Check for New file & Unreserve
            case FileMode.OpenOrCreate:         // Check for new file
            case FileMode.Truncate:             // Unreserve old file size
            case FileMode.Append:               // Check for new file
            case FileMode.Open:                 // Open existing, else exception
                break;

            default:
                throw new ArgumentException(SR.IsolatedStorage_FileOpenMode);
            }

            InitialiationData data = new InitialiationData
            {
                FullPath    = isf.GetFullPath(path),
                StorageFile = isf
            };

            try
            {
                data.NestedStream = new FileStream(data.FullPath, mode, access, share, bufferSize, FileOptions.None);
            }
            catch (Exception e)
            {
                // Make an attempt to clean up the StorageFile if we created it
                try
                {
                    if (createdStore)
                    {
                        data.StorageFile?.Dispose();
                    }
                }
                catch
                {
                }

                // Exception message might leak the IsolatedStorage path. The .NET Framework prevented this by calling an
                // internal API which made sure that the exception message was scrubbed. However since the innerException
                // is never returned to the user(GetIsolatedStorageException() does not populate the innerexception
                // in retail bits we leak the path only under the debugger via IsolatedStorageException._underlyingException which
                // they can any way look at via IsolatedStorageFile instance as well.
                throw IsolatedStorageFile.GetIsolatedStorageException(SR.IsolatedStorage_Operation_ISFS, e);
            }

            return(data);
        }
All Usage Examples Of System.IO.IsolatedStorage.IsolatedStorageFile::GetUserStoreForDomain