Export (0) Print
Expand All

IsolatedStorageFile Class

Represents an isolated storage area containing files and directories.

System.Object
  System.MarshalByRefObject
    System.IO.IsolatedStorage.IsolatedStorage
      System.IO.IsolatedStorage.IsolatedStorageFile

Namespace:  System.IO.IsolatedStorage
Assembly:  mscorlib (in mscorlib.dll)

[ComVisibleAttribute(true)]
public sealed class IsolatedStorageFile : IsolatedStorage, 
	IDisposable

The IsolatedStorageFile type exposes the following members.

  NameDescription
Public propertyApplicationIdentityGets an application identity that scopes isolated storage. (Inherited from IsolatedStorage.)
Public propertyAssemblyIdentityGets an assembly identity used to scope isolated storage. (Inherited from IsolatedStorage.)
Public propertyAvailableFreeSpaceGets a value that represents the amount of free space available for isolated storage. (Overrides IsolatedStorage.AvailableFreeSpace.)
Public propertyCurrentSize Obsolete. Gets the current size of the isolated storage. (Overrides IsolatedStorage.CurrentSize.)
Public propertyDomainIdentityGets a domain identity that scopes isolated storage. (Inherited from IsolatedStorage.)
Public propertyStatic memberIsEnabledGets a value that indicates whether isolated storage is enabled.
Public propertyMaximumSize Obsolete. Gets a value representing the maximum amount of space available for isolated storage within the limits established by the quota. (Overrides IsolatedStorage.MaximumSize.)
Public propertyQuotaGets a value that represents the maximum amount of space available for isolated storage. (Overrides IsolatedStorage.Quota.)
Public propertyScopeGets an IsolatedStorageScope enumeration value specifying the scope used to isolate the store. (Inherited from IsolatedStorage.)
Public propertyUsedSizeGets a value that represents the amount of the space used for isolated storage. (Overrides IsolatedStorage.UsedSize.)
Top

  NameDescription
Public methodCloseCloses a store previously opened with GetStore, GetUserStoreForAssembly, or GetUserStoreForDomain.
Public methodCopyFile(String, String)Copies an existing file to a new file.
Public methodCopyFile(String, String, Boolean)Copies an existing file to a new file, and optionally overwrites an existing file.
Public methodCreateDirectoryCreates a directory in the isolated storage scope.
Public methodCreateFileCreates a file in the isolated store.
Public methodCreateObjRefCreates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from MarshalByRefObject.)
Public methodDeleteDirectoryDeletes a directory in the isolated storage scope.
Public methodDeleteFileDeletes a file in the isolated storage scope.
Public methodDirectoryExistsDetermines whether the specified path refers to an existing directory in the isolated store.
Public methodDisposeReleases all resources used by the IsolatedStorageFile.
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Public methodFileExistsDetermines whether the specified path refers to an existing file in the isolated store.
Public methodGetCreationTimeReturns the creation date and time of a specified file or directory.
Public methodGetDirectoryNames()Enumerates the directories at the root of an isolated store.
Public methodGetDirectoryNames(String)Enumerates the directories in an isolated storage scope that match a given search pattern.
Public methodStatic memberGetEnumeratorGets the enumerator for the IsolatedStorageFile stores within an isolated storage scope.
Public methodGetFileNames()Enumerates the file names at the root of an isolated store.
Public methodGetFileNames(String)Gets the file names that match a search pattern.
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetLastAccessTimeReturns the date and time a specified file or directory was last accessed.
Public methodGetLastWriteTimeReturns the date and time a specified file or directory was last written to.
Public methodGetLifetimeServiceRetrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from MarshalByRefObject.)
Public methodStatic memberGetMachineStoreForApplicationObtains machine-scoped isolated storage corresponding to the calling code's application identity.
Public methodStatic memberGetMachineStoreForAssemblyObtains machine-scoped isolated storage corresponding to the calling code's assembly identity.
Public methodStatic memberGetMachineStoreForDomainObtains machine-scoped isolated storage corresponding to the application domain identity and the assembly identity.
Public methodStatic memberGetStore(IsolatedStorageScope, Object)Obtains isolated storage corresponding to the given application identity.
Public methodStatic memberGetStore(IsolatedStorageScope, Type)Obtains isolated storage corresponding to the isolation scope and the application identity object.
Public methodStatic memberGetStore(IsolatedStorageScope, Object, Object)Obtains the isolated storage corresponding to the given application domain and assembly evidence objects.
Public methodStatic memberGetStore(IsolatedStorageScope, Type, Type)Obtains isolated storage corresponding to the isolated storage scope given the application domain and assembly evidence types.
Public methodStatic memberGetStore(IsolatedStorageScope, Evidence, Type, Evidence, Type)Obtains isolated storage corresponding to the given application domain and the assembly evidence objects and types.
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodStatic memberGetUserStoreForApplicationObtains user-scoped isolated storage corresponding to the calling code's application identity.
Public methodStatic memberGetUserStoreForAssemblyObtains user-scoped isolated storage corresponding to the calling code's assembly identity.
Public methodStatic memberGetUserStoreForDomainObtains user-scoped isolated storage corresponding to the application domain identity and assembly identity.
Public methodStatic memberGetUserStoreForSiteInfrastructure. Obtains a user-scoped isolated store for use by applications in a virtual host domain.
Public methodIncreaseQuotaToEnables an application to explicitly request a larger quota size, in bytes. (Overrides IsolatedStorage.IncreaseQuotaTo(Int64).)
Public methodInitializeLifetimeServiceObtains a lifetime service object to control the lifetime policy for this instance. (Inherited from MarshalByRefObject.)
Public methodMoveDirectoryMoves a specified directory and its contents to a new location.
Public methodMoveFileMoves a specified file to a new location, and optionally lets you specify a new file name.
Public methodOpenFile(String, FileMode)Opens a file in the specified mode.
Public methodOpenFile(String, FileMode, FileAccess)Opens a file in the specified mode with the specified read/write access.
Public methodOpenFile(String, FileMode, FileAccess, FileShare)Opens a file in the specified mode, with the specified read/write access and sharing permission.
Public methodRemove()Removes the isolated storage scope and all its contents. (Overrides IsolatedStorage.Remove().)
Public methodStatic memberRemove(IsolatedStorageScope)Removes the specified isolated storage scope for all identities.
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

This object corresponds to a specific isolated storage scope, where files represented by IsolatedStorageFileStream objects exist. Applications can use isolated storage to save data in their own isolated portion of the file system, without having to specify a particular path within the file system. Since isolated stores are scoped to particular assemblies, most other managed code will not be able to access your code's data (highly trusted managed code and administration tools can access stores from other assemblies). Unmanaged code can access any isolated stores.

For more information, see Isolated Storage.

This type implements the IDisposable interface. When you have finished using the type, you should dispose of it either directly or indirectly. To dispose of the type directly, call its Dispose method in a try/catch block. To dispose of it indirectly, use a language construct such as using (in C#) or Using (in Visual Basic). For more information, see the “Using an Object that Implements IDisposable” section in the IDisposable interface topic.

Important noteImportant

Isolated storage is not available for Windows Store apps. Instead, use the application data classes in the Windows.Storage namespaces included in the Windows Runtime API to store local data and files. For more information, see Application data in the Windows Dev Center.

The following code example illustrates how to create files and directories in an isolated store. First, a store that is isolated by user, domain, and assembly is retrieved and placed in the isoStore variable. The CreateDirectory method is then called to create directories, and two instances of the IsolatedStorageFileStream class create files in these directories.

using System;
using System.IO;
using System.IO.IsolatedStorage;

public class CreatingFilesDirectories
{
    public static void Main()
    {
        using (IsolatedStorageFile isoStore = IsolatedStorageFile.GetStore(IsolatedStorageScope.User | IsolatedStorageScope.Domain | IsolatedStorageScope.Assembly, null, null))
        {
            isoStore.CreateDirectory("TopLevelDirectory");
            isoStore.CreateDirectory("TopLevelDirectory/SecondLevel");
            isoStore.CreateDirectory("AnotherTopLevelDirectory/InsideDirectory");
            Console.WriteLine("Created directories.");

            isoStore.CreateFile("InTheRoot.txt");
            Console.WriteLine("Created a new file in the root.");

            isoStore.CreateFile("AnotherTopLevelDirectory/InsideDirectory/HereIAm.txt");
            Console.WriteLine("Created a new file in the InsideDirectory.");
        }
    }
}

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

.NET for Windows Phone apps

Supported in: Windows Phone 8.1, Windows Phone 8, Silverlight 8.1

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2014 Microsoft