IsolatedStorageFile IsolatedStorageFile IsolatedStorageFile IsolatedStorageFile Class

Definition

Represents an isolated storage area containing files and directories.

public ref class IsolatedStorageFile sealed : System::IO::IsolatedStorage::IsolatedStorage, IDisposable
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class IsolatedStorageFile : System.IO.IsolatedStorage.IsolatedStorage, IDisposable
type IsolatedStorageFile = class
    inherit IsolatedStorage
    interface IDisposable
Public NotInheritable Class IsolatedStorageFile
Inherits IsolatedStorage
Implements IDisposable
Inheritance
Attributes
Implements

Examples

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.");
        }
    }
}
Imports System.IO
Imports System.IO.IsolatedStorage

Module Module1
    Sub Main()
        Using isoStore As IsolatedStorageFile = IsolatedStorageFile.GetStore(IsolatedStorageScope.User Or IsolatedStorageScope.Assembly Or IsolatedStorageScope.Domain, Nothing, Nothing)

            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.")
        End Using
    End Sub
End Module

Remarks

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

Isolated storage is not available for Windows 8.x 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.

Properties

ApplicationIdentity ApplicationIdentity ApplicationIdentity ApplicationIdentity

Gets an application identity that scopes isolated storage.

(Inherited from IsolatedStorage)
AssemblyIdentity AssemblyIdentity AssemblyIdentity AssemblyIdentity

Gets an assembly identity used to scope isolated storage.

(Inherited from IsolatedStorage)
AvailableFreeSpace AvailableFreeSpace AvailableFreeSpace AvailableFreeSpace

Gets a value that represents the amount of free space available for isolated storage.

CurrentSize CurrentSize CurrentSize CurrentSize

Gets the current size of the isolated storage.

DomainIdentity DomainIdentity DomainIdentity DomainIdentity

Gets a domain identity that scopes isolated storage.

(Inherited from IsolatedStorage)
IsEnabled IsEnabled IsEnabled IsEnabled

Gets a value that indicates whether isolated storage is enabled.

MaximumSize MaximumSize MaximumSize MaximumSize

Gets a value representing the maximum amount of space available for isolated storage within the limits established by the quota.

Quota Quota Quota Quota

Gets a value that represents the maximum amount of space available for isolated storage.

Scope Scope Scope Scope

Gets an IsolatedStorageScope enumeration value specifying the scope used to isolate the store.

(Inherited from IsolatedStorage)
SeparatorExternal SeparatorExternal SeparatorExternal SeparatorExternal

Gets a backslash character that can be used in a directory string. When overridden in a derived class, another character might be returned.

(Inherited from IsolatedStorage)
SeparatorInternal SeparatorInternal SeparatorInternal SeparatorInternal

Gets a period character that can be used in a directory string. When overridden in a derived class, another character might be returned.

(Inherited from IsolatedStorage)
UsedSize UsedSize UsedSize UsedSize

Gets a value that represents the amount of the space used for isolated storage.

Methods

Close() Close() Close() Close()

Closes a store previously opened with GetStore(IsolatedStorageScope, Type, Type), GetUserStoreForAssembly(), or GetUserStoreForDomain().

CopyFile(String, String) CopyFile(String, String) CopyFile(String, String) CopyFile(String, String)

Copies an existing file to a new file.

CopyFile(String, String, Boolean) CopyFile(String, String, Boolean) CopyFile(String, String, Boolean) CopyFile(String, String, Boolean)

Copies an existing file to a new file, and optionally overwrites an existing file.

CreateDirectory(String) CreateDirectory(String) CreateDirectory(String) CreateDirectory(String)

Creates a directory in the isolated storage scope.

CreateFile(String) CreateFile(String) CreateFile(String) CreateFile(String)

Creates a file in the isolated store.

CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type)

Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.

(Inherited from MarshalByRefObject)
DeleteDirectory(String) DeleteDirectory(String) DeleteDirectory(String) DeleteDirectory(String)

Deletes a directory in the isolated storage scope.

DeleteFile(String) DeleteFile(String) DeleteFile(String) DeleteFile(String)

Deletes a file in the isolated storage scope.

DirectoryExists(String) DirectoryExists(String) DirectoryExists(String) DirectoryExists(String)

Determines whether the specified path refers to an existing directory in the isolated store.

Dispose() Dispose() Dispose() Dispose()

Releases all resources used by the IsolatedStorageFile.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
FileExists(String) FileExists(String) FileExists(String) FileExists(String)

Determines whether the specified path refers to an existing file in the isolated store.

Finalize() Finalize() Finalize() Finalize()

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.

GetCreationTime(String) GetCreationTime(String) GetCreationTime(String) GetCreationTime(String)

Returns the creation date and time of a specified file or directory.

GetDirectoryNames() GetDirectoryNames() GetDirectoryNames() GetDirectoryNames()

Enumerates the directories at the root of an isolated store.

GetDirectoryNames(String) GetDirectoryNames(String) GetDirectoryNames(String) GetDirectoryNames(String)

Enumerates the directories in an isolated storage scope that match a given search pattern.

GetEnumerator(IsolatedStorageScope) GetEnumerator(IsolatedStorageScope) GetEnumerator(IsolatedStorageScope) GetEnumerator(IsolatedStorageScope)

Gets the enumerator for the IsolatedStorageFile stores within an isolated storage scope.

GetFileNames() GetFileNames() GetFileNames() GetFileNames()

Enumerates the file names at the root of an isolated store.

GetFileNames(String) GetFileNames(String) GetFileNames(String) GetFileNames(String)

Gets the file names that match a search pattern.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetLastAccessTime(String) GetLastAccessTime(String) GetLastAccessTime(String) GetLastAccessTime(String)

Returns the date and time a specified file or directory was last accessed.

GetLastWriteTime(String) GetLastWriteTime(String) GetLastWriteTime(String) GetLastWriteTime(String)

Returns the date and time a specified file or directory was last written to.

GetLifetimeService() GetLifetimeService() GetLifetimeService() GetLifetimeService()

Retrieves the current lifetime service object that controls the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
GetMachineStoreForApplication() GetMachineStoreForApplication() GetMachineStoreForApplication() GetMachineStoreForApplication()

Obtains machine-scoped isolated storage corresponding to the calling code's application identity.

GetMachineStoreForAssembly() GetMachineStoreForAssembly() GetMachineStoreForAssembly() GetMachineStoreForAssembly()

Obtains machine-scoped isolated storage corresponding to the calling code's assembly identity.

GetMachineStoreForDomain() GetMachineStoreForDomain() GetMachineStoreForDomain() GetMachineStoreForDomain()

Obtains machine-scoped isolated storage corresponding to the application domain identity and the assembly identity.

GetPermission(PermissionSet) GetPermission(PermissionSet) GetPermission(PermissionSet) GetPermission(PermissionSet)

When implemented by a derived class, returns a permission that represents access to isolated storage from within a permission set.

(Inherited from IsolatedStorage)
GetStore(IsolatedStorageScope, Evidence, Type, Evidence, Type) GetStore(IsolatedStorageScope, Evidence, Type, Evidence, Type) GetStore(IsolatedStorageScope, Evidence, Type, Evidence, Type) GetStore(IsolatedStorageScope, Evidence, Type, Evidence, Type)

Obtains isolated storage corresponding to the given application domain and the assembly evidence objects and types.

GetStore(IsolatedStorageScope, Object) GetStore(IsolatedStorageScope, Object) GetStore(IsolatedStorageScope, Object) GetStore(IsolatedStorageScope, Object)

Obtains isolated storage corresponding to the given application identity.

GetStore(IsolatedStorageScope, Object, Object) GetStore(IsolatedStorageScope, Object, Object) GetStore(IsolatedStorageScope, Object, Object) GetStore(IsolatedStorageScope, Object, Object)

Obtains the isolated storage corresponding to the given application domain and assembly evidence objects.

GetStore(IsolatedStorageScope, Type) GetStore(IsolatedStorageScope, Type) GetStore(IsolatedStorageScope, Type) GetStore(IsolatedStorageScope, Type)

Obtains isolated storage corresponding to the isolation scope and the application identity object.

GetStore(IsolatedStorageScope, Type, Type) GetStore(IsolatedStorageScope, Type, Type) GetStore(IsolatedStorageScope, Type, Type) GetStore(IsolatedStorageScope, Type, Type)

Obtains isolated storage corresponding to the isolated storage scope given the application domain and assembly evidence types.

GetType() GetType() GetType() GetType()

Gets the Type of the current instance.

(Inherited from Object)
GetUserStoreForApplication() GetUserStoreForApplication() GetUserStoreForApplication() GetUserStoreForApplication()

Obtains user-scoped isolated storage corresponding to the calling code's application identity.

GetUserStoreForAssembly() GetUserStoreForAssembly() GetUserStoreForAssembly() GetUserStoreForAssembly()

Obtains user-scoped isolated storage corresponding to the calling code's assembly identity.

GetUserStoreForDomain() GetUserStoreForDomain() GetUserStoreForDomain() GetUserStoreForDomain()

Obtains user-scoped isolated storage corresponding to the application domain identity and assembly identity.

GetUserStoreForSite() GetUserStoreForSite() GetUserStoreForSite() GetUserStoreForSite()

Obtains a user-scoped isolated store for use by applications in a virtual host domain.

IncreaseQuotaTo(Int64) IncreaseQuotaTo(Int64) IncreaseQuotaTo(Int64) IncreaseQuotaTo(Int64)

Enables an application to explicitly request a larger quota size, in bytes.

InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService()

Obtains a lifetime service object to control the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
InitStore(IsolatedStorageScope, Type) InitStore(IsolatedStorageScope, Type) InitStore(IsolatedStorageScope, Type) InitStore(IsolatedStorageScope, Type)

Initializes a new IsolatedStorage object.

(Inherited from IsolatedStorage)
InitStore(IsolatedStorageScope, Type, Type) InitStore(IsolatedStorageScope, Type, Type) InitStore(IsolatedStorageScope, Type, Type) InitStore(IsolatedStorageScope, Type, Type)

Initializes a new IsolatedStorage object.

(Inherited from IsolatedStorage)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
MemberwiseClone(Boolean) MemberwiseClone(Boolean) MemberwiseClone(Boolean) MemberwiseClone(Boolean)

Creates a shallow copy of the current MarshalByRefObject object.

(Inherited from MarshalByRefObject)
MoveDirectory(String, String) MoveDirectory(String, String) MoveDirectory(String, String) MoveDirectory(String, String)

Moves a specified directory and its contents to a new location.

MoveFile(String, String) MoveFile(String, String) MoveFile(String, String) MoveFile(String, String)

Moves a specified file to a new location, and optionally lets you specify a new file name.

OpenFile(String, FileMode) OpenFile(String, FileMode) OpenFile(String, FileMode) OpenFile(String, FileMode)

Opens a file in the specified mode.

OpenFile(String, FileMode, FileAccess) OpenFile(String, FileMode, FileAccess) OpenFile(String, FileMode, FileAccess) OpenFile(String, FileMode, FileAccess)

Opens a file in the specified mode with the specified read/write access.

OpenFile(String, FileMode, FileAccess, FileShare) OpenFile(String, FileMode, FileAccess, FileShare) OpenFile(String, FileMode, FileAccess, FileShare) OpenFile(String, FileMode, FileAccess, FileShare)

Opens a file in the specified mode, with the specified read/write access and sharing permission.

Remove() Remove() Remove() Remove()

Removes the isolated storage scope and all its contents.

Remove(IsolatedStorageScope) Remove(IsolatedStorageScope) Remove(IsolatedStorageScope) Remove(IsolatedStorageScope)

Removes the specified isolated storage scope for all identities.

ToString() ToString() ToString() ToString()

Returns a string that represents the current object.

(Inherited from Object)

Applies to

See also