IsolatedStorageFile 類別

定義

代表包含檔案和目錄的隔離儲存區 (Isolated Storage) 之區域。

public ref class IsolatedStorageFile sealed : IDisposable
public ref class IsolatedStorageFile sealed : System::IO::IsolatedStorage::IsolatedStorage, IDisposable
public sealed class IsolatedStorageFile : IDisposable
public sealed class IsolatedStorageFile : System.IO.IsolatedStorage.IsolatedStorage, IDisposable
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class IsolatedStorageFile : System.IO.IsolatedStorage.IsolatedStorage, IDisposable
type IsolatedStorageFile = class
    interface IDisposable
type IsolatedStorageFile = class
    inherit IsolatedStorage
    interface IDisposable
[<System.Runtime.InteropServices.ComVisible(true)>]
type IsolatedStorageFile = class
    inherit IsolatedStorage
    interface IDisposable
Public NotInheritable Class IsolatedStorageFile
Implements IDisposable
Public NotInheritable Class IsolatedStorageFile
Inherits IsolatedStorage
Implements IDisposable
繼承
IsolatedStorageFile
繼承
屬性
實作

範例

下列程式碼範例說明如何在隔離存放區中建立檔案和目錄。 首先,會擷取使用者、網域和元件隔離的存放區,並將其放在 變數中 isoStore 。 接著會 CreateDirectory 呼叫 方法來建立目錄,而 類別的 IsolatedStorageFileStream 兩個實例會在這些目錄中建立檔案。

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

備註

此物件會對應至特定隔離儲存範圍,其中物件所代表的 IsolatedStorageFileStream 檔案存在。 應用程式可以使用隔離儲存區將資料儲存在檔案系統本身的隔離部分,而不需要在檔案系統內指定特定路徑。 由於隔離存放區的範圍僅限於特定元件,因此大部分的其他 Managed 程式碼將無法存取程式碼的資料 (高度信任的 Managed 程式碼,而管理工具可以從其他元件存取存放區) 。 Unmanaged 程式碼可以存取任何隔離的存放區。

如需詳細資訊,請參閱 隔離儲存區

此型別代表 IDisposable 介面。 當您完成使用型別時,您應該直接或間接處置它。 若要直接處置型別,請呼叫其 try/catch 區塊中的 Dispose 方法。 若要間接處置它,請使用語言建構函式,例如 using (在 C# 中) 或 Using (在 Visual Basic 中)。 如需詳細資訊,請參閱 IDisposable 介面文章中的<使用實作 IDisposable 的物件>一節。

重要

隔離儲存區不適用於 Windows 8.x 市集應用程式。 請改用 Windows 執行階段 API 所提供的 Windows.Storage 命名空間來儲存本機資料與檔案。 如需詳細資訊,請參閱 Windows 開發人員中心的應用程式資料

屬性

ApplicationIdentity

取得限定隔離儲存區 (Isolated Storage) 範圍的應用程式識別 (Identity)。

(繼承來源 IsolatedStorage)
AssemblyIdentity

取得用來限定隔離儲存區範圍的組件識別 (Assembly Identity)。

(繼承來源 IsolatedStorage)
AvailableFreeSpace

取得值,這個值表示隔離儲存區的可用空間量。

AvailableFreeSpace

在衍生類別中覆寫時,取得隔離儲存區的可用空間 (以位元組為單位)。

(繼承來源 IsolatedStorage)
CurrentSize
已淘汰.
已淘汰.

取得隔離儲存區目前的大小。

DomainIdentity

取得限定隔離儲存區範圍的網域識別。

(繼承來源 IsolatedStorage)
IsEnabled

取得值,這個值表示隔離儲存區是否啟用。

MaximumSize
已淘汰.
已淘汰.

取得值,表示隔離儲存區在配額建立起來的限制內可以使用的最大空間量。

Quota

取得值,這個值表示隔離儲存區的最大可用空間量。

Quota

在衍生類別中覆寫時取得值,這個值表示隔離儲存區空間的最大可用空間量。

(繼承來源 IsolatedStorage)
Scope

取得 IsolatedStorageScope 列舉型別值,指定用來隔離存放區的範圍。

(繼承來源 IsolatedStorage)
SeparatorExternal

取得可以用在目錄字串中的反斜線字元。 當在衍生類別中覆寫時,可能會傳回另一個字元。

(繼承來源 IsolatedStorage)
SeparatorInternal

取得可以用在目錄字串中的句號字元。 當在衍生類別中覆寫時,可能會傳回另一個字元。

(繼承來源 IsolatedStorage)
UsedSize

取得值,這個值表示隔離儲存區的已使用空間量。

UsedSize

在衍生類別中覆寫時,取得值,這個值表示隔離儲存區的已使用空間量。

(繼承來源 IsolatedStorage)

方法

Close()

關閉先前由 GetStore(IsolatedStorageScope, Type, Type)GetUserStoreForAssembly()GetUserStoreForDomain() 開啟的存放區。

CopyFile(String, String)

複製現有的檔案到新的檔案。

CopyFile(String, String, Boolean)

複製現有的檔案到新檔案,並選擇性地覆寫現有的檔案。

CreateDirectory(String)

在隔離儲存區範圍內建立目錄。

CreateFile(String)

在隔離儲存區中建立檔案。

CreateObjRef(Type)

建立包含所有相關資訊的物件,這些資訊是產生用來與遠端物件通訊的所需 Proxy。

(繼承來源 MarshalByRefObject)
DeleteDirectory(String)

刪除隔離儲存區範圍內的目錄。

DeleteFile(String)

刪除隔離儲存區範圍內的檔案。

DirectoryExists(String)

判斷指定路徑是否參考隔離儲存區中的現有目錄。

Dispose()

釋放 IsolatedStorageFile 所使用的所有資源。

Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
FileExists(String)

判斷指定路徑是否參考隔離儲存區中的現有檔案。

Finalize()

允許物件在記憶體回收進行回收之前,嘗試釋放資源並執行其他清除作業。

GetCreationTime(String)

傳回指定之檔案或目錄的建立日期和時間。

GetDirectoryNames()

列舉位於隔離儲存區根目錄的目錄。

GetDirectoryNames(String)

列舉隔離儲存區範圍中符合指定之搜尋模式的目錄。

GetEnumerator(IsolatedStorageScope)

取得隔離儲存區範圍中 IsolatedStorageFile 存放區的列舉程式。

GetFileNames()

列舉位於隔離儲存區根目錄的檔名。

GetFileNames(String)

取得符合搜尋模式的檔名。

GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetLastAccessTime(String)

傳回指定之檔案或目錄上次被存取的日期和時間。

GetLastWriteTime(String)

傳回指定之檔案或目錄上次被寫入的日期和時間。

GetLifetimeService()
已淘汰.

擷取控制這個執行個體存留期 (Lifetime) 原則的目前存留期服務物件。

(繼承來源 MarshalByRefObject)
GetMachineStoreForApplication()

取得對應於呼叫程式碼的應用程式識別之機器範圍隔離儲存區。

GetMachineStoreForAssembly()

取得對應於呼叫程式碼的組件識別之機器範圍隔離儲存區。

GetMachineStoreForDomain()

取得對應於應用程式定義域識別和組件識別的機器範圍隔離儲存區。

GetPermission(PermissionSet)

在由衍生類別實作時,會從使用權限集合中傳回表示存取隔離儲存區的使用權限。

(繼承來源 IsolatedStorage)
GetStore(IsolatedStorageScope, Evidence, Type, Evidence, Type)

取得對應於指定應用程式定義域、組件辨識項物件和類型的隔離儲存區。

GetStore(IsolatedStorageScope, Object)

取得對應於指定的應用程式識別之隔離儲存區。

GetStore(IsolatedStorageScope, Object, Object)

取得對應於指定應用程式定義域和組件辨識項物件的隔離儲存區。

GetStore(IsolatedStorageScope, Type)

取得對應於隔離範圍和應用程式識別物件之隔離儲存區。

GetStore(IsolatedStorageScope, Type, Type)

取得對應於指定應用程式定義域的隔離儲存區範圍和組件辨識項碼型的隔離儲存區。

GetType()

取得目前執行個體的 Type

(繼承來源 Object)
GetUserStoreForApplication()

取得對應於呼叫程式碼的應用程式識別之使用者範圍隔離儲存區。

GetUserStoreForAssembly()

取得對應於呼叫程式碼的組件識別之使用者範圍隔離儲存區。

GetUserStoreForDomain()

取得對應於應用程式定義域識別和組件識別的使用者範圍隔離儲存區。

GetUserStoreForSite()

取得使用者範圍隔離儲存區,以供虛擬主應用程式定義域中的應用程式使用。

IncreaseQuotaTo(Int64)

讓應用程式明確要求更大的配額大小 (以位元組為單位)。

IncreaseQuotaTo(Int64)

在衍生類別中覆寫時,提示使用者核准更大的隔離儲存區配額大小 (以位元組為單位)。

(繼承來源 IsolatedStorage)
InitializeLifetimeService()
已淘汰.

取得存留期服務物件,以控制這個執行個體的存留期原則。

(繼承來源 MarshalByRefObject)
InitStore(IsolatedStorageScope, Type)

初始化新的 IsolatedStorage 物件。

(繼承來源 IsolatedStorage)
InitStore(IsolatedStorageScope, Type, Type)

初始化新的 IsolatedStorage 物件。

(繼承來源 IsolatedStorage)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
MemberwiseClone(Boolean)

建立目前 MarshalByRefObject 物件的淺層複本。

(繼承來源 MarshalByRefObject)
MoveDirectory(String, String)

移動指定的目錄和其內容到新位置。

MoveFile(String, String)

移動指定的檔案至新的位置,並選擇性地讓您指定新檔名。

OpenFile(String, FileMode)

使用指定模式來開啟檔案。

OpenFile(String, FileMode, FileAccess)

使用指定的讀取/寫入存取,並以指定模式來開啟檔案。

OpenFile(String, FileMode, FileAccess, FileShare)

使用指定的讀取/寫入存取和共用使用權限,並以指定模式來開啟檔案。

Remove()

移除隔離儲存區範圍和所有內容。

Remove(IsolatedStorageScope)

移除所有識別的指定隔離儲存區範圍。

ToString()

傳回代表目前物件的字串。

(繼承來源 Object)

適用於

另請參閱