IsolatedStorageFileStream 构造函数

定义

初始化 IsolatedStorageFileStream 类的新实例。Initializes a new instance of the IsolatedStorageFileStream class. 打开 IsolatedStorageFileStream 的唯一方法是使用它的一个构造函数。The only way to open an IsolatedStorageFileStream is by using one of its constructors.

重载

IsolatedStorageFileStream(String, FileMode)

初始化 IsolatedStorageFileStream 对象的新实例,通过该实例可以访问指定 path 中的 mode 指定的文件。Initializes a new instance of an IsolatedStorageFileStream object giving access to the file designated by path in the specified mode.

IsolatedStorageFileStream(String, FileMode, FileAccess)

初始化 IsolatedStorageFileStream 类的一个新实例,以便可以指定的 path、用请求类型的 mode 访问 access 所指定的文件。Initializes a new instance of the IsolatedStorageFileStream class giving access to the file designated by path, in the specified mode, with the kind of access requested.

IsolatedStorageFileStream(String, FileMode, IsolatedStorageFile)

初始化 IsolatedStorageFileStream 类的一个新实例,以便可以在 path 指定的 mode 的上下文中,以指定的 IsolatedStorageFile 来访问 isf 所指定的文件。Initializes a new instance of the IsolatedStorageFileStream class giving access to the file designated by path, in the specified mode, and in the context of the IsolatedStorageFile specified by isf.

IsolatedStorageFileStream(String, FileMode, FileAccess, FileShare)

初始化 IsolatedStorageFileStream 类的一个新实例,以便可以使用 path 指定的文件共享模式,以指定的 mode、用指定的文件 access 访问 share 所指定的文件。Initializes a new instance of the IsolatedStorageFileStream class giving access to the file designated by path, in the specified mode, with the specified file access, using the file sharing mode specified by share.

IsolatedStorageFileStream(String, FileMode, FileAccess, IsolatedStorageFile)

初始化 IsolatedStorageFileStream 类的一个新实例,以便可以在 path 所指定的 mode 的上下文中,以指定的 access、用指定的文件 IsolatedStorageFile 来访问 isf 所指定的文件。Initializes a new instance of the IsolatedStorageFileStream class giving access to the file designated by path in the specified mode, with the specified file access, and in the context of the IsolatedStorageFile specified by isf.

IsolatedStorageFileStream(String, FileMode, FileAccess, FileShare, Int32)

初始化 IsolatedStorageFileStream 类的一个新实例,以便可以使用 path 指定的文件共享模式(指定了 mode),以指定的 access、用指定的文件 share 访问 buffersize 所指定的文件。Initializes a new instance of the IsolatedStorageFileStream class giving access to the file designated by path, in the specified mode, with the specified file access, using the file sharing mode specified by share, with the buffersize specified.

IsolatedStorageFileStream(String, FileMode, FileAccess, FileShare, IsolatedStorageFile)

初始化 IsolatedStorageFileStream 类的一个新实例,以便可以在 path 指定的 mode 的上下文中,使用 access 指定的文件共享模式,以指定的 share、用指定的文件 IsolatedStorageFile 来访问 isf 所指定的文件。Initializes a new instance of the IsolatedStorageFileStream class giving access to the file designated by path, in the specified mode, with the specified file access, using the file sharing mode specified by share, and in the context of the IsolatedStorageFile specified by isf.

IsolatedStorageFileStream(String, FileMode, FileAccess, FileShare, Int32, IsolatedStorageFile)

初始化 IsolatedStorageFileStream 类的一个新实例,以便可以在 path 指定的 mode 的上下文中,使用 access 指定的文件享模式(指定了 share),以指定的 buffersize、用指定的文件 IsolatedStorageFile 来访问 isf 所指定的文件。Initializes a new instance of the IsolatedStorageFileStream class giving access to the file designated by path, in the specified mode, with the specified file access, using the file sharing mode specified by share, with the buffersize specified, and in the context of the IsolatedStorageFile specified by isf.

IsolatedStorageFileStream(String, FileMode)

初始化 IsolatedStorageFileStream 对象的新实例,通过该实例可以访问指定 path 中的 mode 指定的文件。Initializes a new instance of an IsolatedStorageFileStream object giving access to the file designated by path in the specified mode.

public:
 IsolatedStorageFileStream(System::String ^ path, System::IO::FileMode mode);
public IsolatedStorageFileStream (string path, System.IO.FileMode mode);
new System.IO.IsolatedStorage.IsolatedStorageFileStream : string * System.IO.FileMode -> System.IO.IsolatedStorage.IsolatedStorageFileStream
Public Sub New (path As String, mode As FileMode)

参数

path
String

独立存储区内文件的相对路径。The relative path of the file within isolated storage.

mode
FileMode

FileMode 值之一。One of the FileMode values.

例外

path 的格式不正确。The path is badly formed.

pathnullThe path is null.

path 中的目录不存在。The directory in path does not exist.

未找到任何文件,且 mode 设置为 OpenNo file was found and the mode is set to Open

注解

使用的独立存储区的范围由当前执行程序集的标识和运行它的应用程序域的标识确定。The isolated store that is used is scoped by the current executing assembly's identity and that of the application domain in which it is running. 此存储将在 IsolatedStorageFileStream 对象的生存期内保持打开状态。This store will remain open only for the lifetime of the IsolatedStorageFileStream object. 若要指定不同的独立存储范围,或允许存储保持打开状态(以便可以从其打开多个 IsolatedStorageFileStream 对象),请使用接受 IsolatedStorageFile 对象的构造函数的形式。To specify a different isolated storage scope, or to allow the store to remain open (so multiple IsolatedStorageFileStream objects can be opened from it), use the form of the constructor that accepts an IsolatedStorageFile object.

mode 参数指示是应该创建新文件,还是使用现有文件,等等。The mode parameter indicates whether a new file should be created, an existing one used, and so on.

注意

使用特定的区域性设置编译一组字符并使用不同的区域性设置检索这些相同的字符时,这些字符可能无法可解释,并且可能会导致引发异常。When you compile a set of characters with a particular cultural setting and retrieve those same characters with a different cultural setting, the characters might not be interpretable and can cause an exception to be thrown.

IsolatedStorageFileStream(String, FileMode, FileAccess)

初始化 IsolatedStorageFileStream 类的一个新实例,以便可以指定的 path、用请求类型的 mode 访问 access 所指定的文件。Initializes a new instance of the IsolatedStorageFileStream class giving access to the file designated by path, in the specified mode, with the kind of access requested.

public:
 IsolatedStorageFileStream(System::String ^ path, System::IO::FileMode mode, System::IO::FileAccess access);
public IsolatedStorageFileStream (string path, System.IO.FileMode mode, System.IO.FileAccess access);
new System.IO.IsolatedStorage.IsolatedStorageFileStream : string * System.IO.FileMode * System.IO.FileAccess -> System.IO.IsolatedStorage.IsolatedStorageFileStream
Public Sub New (path As String, mode As FileMode, access As FileAccess)

参数

path
String

独立存储区内文件的相对路径。The relative path of the file within isolated storage.

mode
FileMode

FileMode 值之一。One of the FileMode values.

access
FileAccess

FileAccess 值的按位组合。A bitwise combination of the FileAccess values.

例外

path 的格式不正确。The path is badly formed.

pathnullThe path is null.

未找到任何文件,且 mode 设置为 OpenNo file was found and the mode is set to Open.

注解

使用的独立存储区的范围由当前执行程序集的标识和运行它的应用程序域的标识确定。The isolated store that is used is scoped by the current executing assembly's identity and that of the application domain in which it is running. 此存储将在 IsolatedStorageFileStream 对象的生存期内保持打开状态。This store will remain open only for the lifetime of the IsolatedStorageFileStream object. 若要指定不同的独立存储范围,或允许存储保持打开状态(以便可以从其打开多个 IsolatedStorageFileStream 对象),请使用接受 IsolatedStorageFile 对象的构造函数的形式。To specify a different isolated storage scope, or to allow the store to remain open (so multiple IsolatedStorageFileStream objects can be opened from it), use the form of the constructor that accepts an IsolatedStorageFile object.

mode 参数指示是应创建新文件还是使用现有文件。The mode parameter indicates whether a new file should be created or an existing one used. access 参数包括只读、读/写和只写。The access parameter includes read-only, read/write, and write-only.

注意

使用特定的区域性设置编译一组字符,并使用不同的区域性设置检索这些相同的字符时,这些字符可能不可解释,并且可能会导致引发异常。When you compile a set of characters with a particular cultural setting and retrieve those same characters with a different cultural setting, the characters might not be interpretable, and can cause an exception to be thrown.

IsolatedStorageFileStream(String, FileMode, IsolatedStorageFile)

初始化 IsolatedStorageFileStream 类的一个新实例,以便可以在 path 指定的 mode 的上下文中,以指定的 IsolatedStorageFile 来访问 isf 所指定的文件。Initializes a new instance of the IsolatedStorageFileStream class giving access to the file designated by path, in the specified mode, and in the context of the IsolatedStorageFile specified by isf.

public:
 IsolatedStorageFileStream(System::String ^ path, System::IO::FileMode mode, System::IO::IsolatedStorage::IsolatedStorageFile ^ isf);
public IsolatedStorageFileStream (string path, System.IO.FileMode mode, System.IO.IsolatedStorage.IsolatedStorageFile isf);
new System.IO.IsolatedStorage.IsolatedStorageFileStream : string * System.IO.FileMode * System.IO.IsolatedStorage.IsolatedStorageFile -> System.IO.IsolatedStorage.IsolatedStorageFileStream
Public Sub New (path As String, mode As FileMode, isf As IsolatedStorageFile)

参数

path
String

独立存储区内文件的相对路径。The relative path of the file within isolated storage.

mode
FileMode

FileMode 值之一。One of the FileMode values.

例外

path 的格式不正确。The path is badly formed.

pathnullThe path is null.

未找到任何文件,且 mode 设置为 OpenNo file was found and the mode is set to Open.

isf 无配额。isf does not have a quota.

示例

下面的代码示例演示如何使用此构造函数。The following code example demonstrates the use of this constructor. 有关此示例的完整上下文,请参阅 IsolatedStorageFileStream 概述。For the complete context of this example, see the IsolatedStorageFileStream overview.

// This is the stream to which data will be written.
IsolatedStorageFileStream^ source = gcnew IsolatedStorageFileStream( this->userName,FileMode::OpenOrCreate,isoFile );

// This is the stream from which data will be read.
Console::WriteLine( "Is the source file readable?  {0}", (source->CanRead ? (String^)"true" : "false") );
Console::WriteLine( "Creating new IsolatedStorageFileStream for Archive." );

// Open or create a writable file.
IsolatedStorageFileStream^ target = gcnew IsolatedStorageFileStream( String::Concat("Archive\\",this->userName),FileMode::OpenOrCreate,FileAccess::Write,FileShare::Write,isoFile );


IsolatedStorageFileStream source =
    new IsolatedStorageFileStream(this.userName, FileMode.OpenOrCreate,
    isoFile);
// This is the stream from which data will be read.
Console.WriteLine("Is the source file readable? " + (source.CanRead ? "true" : "false"));
Console.WriteLine("Creating new IsolatedStorageFileStream for Archive.");

// Open or create a writable file.
IsolatedStorageFileStream target =
    new IsolatedStorageFileStream("Archive\\ " + this.userName,
    FileMode.OpenOrCreate,
    FileAccess.Write,
    FileShare.Write,
    isoFile);
' Open or create a writable file.
Dim target As New IsolatedStorageFileStream("Archive\ " & Me.userName, _
     FileMode.OpenOrCreate, FileAccess.Write, FileShare.Write, isoFile)

注解

mode 参数指示是应该创建新文件,还是使用现有文件,等等。The mode parameter indicates whether a new file should be created, an existing one used, and so on.

注意

使用特定的区域性设置编译一组字符,并使用不同的区域性设置检索这些相同的字符时,这些字符可能不可解释,并且可能会导致引发异常。When you compile a set of characters with a particular cultural setting and retrieve those same characters with a different cultural setting, the characters might not be interpretable, and can cause an exception to be thrown.

IsolatedStorageFileStream(String, FileMode, FileAccess, FileShare)

初始化 IsolatedStorageFileStream 类的一个新实例,以便可以使用 path 指定的文件共享模式,以指定的 mode、用指定的文件 access 访问 share 所指定的文件。Initializes a new instance of the IsolatedStorageFileStream class giving access to the file designated by path, in the specified mode, with the specified file access, using the file sharing mode specified by share.

public:
 IsolatedStorageFileStream(System::String ^ path, System::IO::FileMode mode, System::IO::FileAccess access, System::IO::FileShare share);
public IsolatedStorageFileStream (string path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share);
new System.IO.IsolatedStorage.IsolatedStorageFileStream : string * System.IO.FileMode * System.IO.FileAccess * System.IO.FileShare -> System.IO.IsolatedStorage.IsolatedStorageFileStream
Public Sub New (path As String, mode As FileMode, access As FileAccess, share As FileShare)

参数

path
String

独立存储区内文件的相对路径。The relative path of the file within isolated storage.

mode
FileMode

FileMode 值之一。One of the FileMode values.

access
FileAccess

FileAccess 值的按位组合。A bitwise combination of the FileAccess values.

share
FileShare

FileShare 值的按位组合。A bitwise combination of the FileShare values.

例外

path 的格式不正确。The path is badly formed.

pathnullThe path is null.

未找到任何文件,且 mode 设置为 OpenNo file was found and the mode is set to Open.

示例

下面的代码示例演示如何使用此构造函数。The following code example demonstrates the use of this constructor. 有关此示例的完整上下文,请参阅 IsolatedStorageFileStream 概述。For the complete context of this example, see the IsolatedStorageFileStream overview.

// Retrieve an IsolatedStorageFile for the current Domain and Assembly.
IsolatedStorageFile^ isoFile = IsolatedStorageFile::GetStore( static_cast<IsolatedStorageScope>(IsolatedStorageScope::User | IsolatedStorageScope::Assembly | IsolatedStorageScope::Domain), (Type^)nullptr, nullptr );
IsolatedStorageFileStream^ isoStream = gcnew IsolatedStorageFileStream( this->userName,FileMode::Open,FileAccess::ReadWrite,isoFile );


// Retrieve an IsolatedStorageFile for the current Domain and Assembly.
IsolatedStorageFile isoFile =
    IsolatedStorageFile.GetStore(IsolatedStorageScope.User |
    IsolatedStorageScope.Assembly |
    IsolatedStorageScope.Domain,
    null,
    null);

IsolatedStorageFileStream isoStream =
    new IsolatedStorageFileStream("substituteUsername",
    System.IO.FileMode.Open,
    System.IO.FileAccess.Read,
     System.IO.FileShare.Read);
' Retrieve an IsolatedStorageFile for the current Domain and Assembly.
Dim isoFile As IsolatedStorageFile = _
    IsolatedStorageFile.GetStore(IsolatedStorageScope.User _
    Or IsolatedStorageScope.Assembly _
    Or IsolatedStorageScope.Domain, Nothing, Nothing)

Dim isoStream As New IsolatedStorageFileStream("substituteUsername", System.IO.FileMode.Open, _
    System.IO.FileAccess.Read, System.IO.FileShare.Read)

注解

使用的独立存储区的范围由当前执行程序集的标识和运行它的应用程序域的标识确定。The isolated store that is used is scoped by the current executing assembly's identity and that of the application domain in which it is running. 此存储将在 IsolatedStorageFileStream 对象的生存期内保持打开状态。This store will remain open only for the lifetime of the IsolatedStorageFileStream object. 若要指定不同的独立存储范围,或允许存储保持打开状态(以便可以从其打开多个 IsolatedStorageFileStream 对象),请使用接受 IsolatedStorageFile 对象的构造函数的形式。To specify a different isolated storage scope, or to allow the store to remain open (so multiple IsolatedStorageFileStream objects can be opened from it), use the form of the constructor that accepts an IsolatedStorageFile object.

注意

使用特定的区域性设置编译一组字符并使用不同的区域性设置检索这些相同的字符时,这些字符可能无法可解释,并且可能会导致引发异常。When you compile a set of characters with a particular cultural setting and retrieve those same characters with a different cultural setting, the characters might not be interpretable and can cause an exception to be thrown.

IsolatedStorageFileStream(String, FileMode, FileAccess, IsolatedStorageFile)

初始化 IsolatedStorageFileStream 类的一个新实例,以便可以在 path 所指定的 mode 的上下文中,以指定的 access、用指定的文件 IsolatedStorageFile 来访问 isf 所指定的文件。Initializes a new instance of the IsolatedStorageFileStream class giving access to the file designated by path in the specified mode, with the specified file access, and in the context of the IsolatedStorageFile specified by isf.

public:
 IsolatedStorageFileStream(System::String ^ path, System::IO::FileMode mode, System::IO::FileAccess access, System::IO::IsolatedStorage::IsolatedStorageFile ^ isf);
public IsolatedStorageFileStream (string path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.IsolatedStorage.IsolatedStorageFile isf);
new System.IO.IsolatedStorage.IsolatedStorageFileStream : string * System.IO.FileMode * System.IO.FileAccess * System.IO.IsolatedStorage.IsolatedStorageFile -> System.IO.IsolatedStorage.IsolatedStorageFileStream
Public Sub New (path As String, mode As FileMode, access As FileAccess, isf As IsolatedStorageFile)

参数

path
String

独立存储区内文件的相对路径。The relative path of the file within isolated storage.

mode
FileMode

FileMode 值之一。One of the FileMode values.

access
FileAccess

FileAccess 值的按位组合。A bitwise combination of the FileAccess values.

例外

path 的格式不正确。The path is badly formed.

pathnullThe path is null.

独立存储关闭。The isolated store is closed.

未找到任何文件,且 mode 设置为 OpenNo file was found and the mode is set to Open.

isf 无配额。isf does not have a quota.

示例

下面的代码示例演示如何使用此构造函数。The following code example demonstrates the use of this constructor. 有关此示例的完整上下文,请参阅 IsolatedStorageFileStream 概述。For the complete context of this example, see the IsolatedStorageFileStream overview.

IsolatedStorageFile^ isoFile;
isoFile = IsolatedStorageFile::GetUserStoreForDomain();

// Open or create a writable file.
IsolatedStorageFileStream^ isoStream = gcnew IsolatedStorageFileStream( this->userName,FileMode::OpenOrCreate,FileAccess::Write,isoFile );
StreamWriter^ writer = gcnew StreamWriter( isoStream );
writer->WriteLine( this->NewsUrl );
writer->WriteLine( this->SportsUrl );

// Calculate the amount of space used to record the user's preferences.
double d = isoFile->CurrentSize / isoFile->MaximumSize;
Console::WriteLine( "CurrentSize = {0}", isoFile->CurrentSize.ToString() );
Console::WriteLine( "MaximumSize = {0}", isoFile->MaximumSize.ToString() );
writer->Close();
isoFile->Close();
isoStream->Close();
return d;

IsolatedStorageFile isoFile;
isoFile = IsolatedStorageFile.GetUserStoreForDomain();

// Open or create a writable file.
IsolatedStorageFileStream isoStream =
    new IsolatedStorageFileStream(this.userName,
    FileMode.OpenOrCreate,
    FileAccess.Write,
    isoFile);

StreamWriter writer = new StreamWriter(isoStream);
writer.WriteLine(this.NewsUrl);
writer.WriteLine(this.SportsUrl);
// Calculate the amount of space used to record the user's preferences.
double d = isoFile.CurrentSize / isoFile.MaximumSize;
Console.WriteLine("CurrentSize = " + isoFile.CurrentSize.ToString());
Console.WriteLine("MaximumSize = " + isoFile.MaximumSize.ToString());
// StreamWriter.Close implicitly closes isoStream.
writer.Close();
isoFile.Dispose();
isoFile.Close();
return d;
Dim isoFile As IsolatedStorageFile
isoFile = IsolatedStorageFile.GetUserStoreForDomain()

' Open or create a writable file.
Dim isoStream As New IsolatedStorageFileStream(Me.userName, FileMode.OpenOrCreate, _
    FileAccess.Write, isoFile)

Dim writer As New StreamWriter(isoStream)
writer.WriteLine(Me.NewsUrl)
writer.WriteLine(Me.SportsUrl)
' Calculate the amount of space used to record the user's preferences.
Dim d As Double = Convert.ToDouble(isoFile.CurrentSize) / Convert.ToDouble(isoFile.MaximumSize)
Console.WriteLine(("CurrentSize = " & isoFile.CurrentSize.ToString()))
Console.WriteLine(("MaximumSize = " & isoFile.MaximumSize.ToString()))
' StreamWriter.Close implicitly closes isoStream.
writer.Close()
isoFile.Dispose()
isoFile.Close()
Return d

注解

mode 参数指示是应创建新文件还是使用现有文件。The mode parameter indicates whether a new file should be created or an existing one used. access 参数包括只读、读/写和只写。The access parameter includes read-only, read/write, and write-only.

注意

使用特定的区域性设置编译一组字符,并使用不同的区域性设置检索这些相同的字符时,这些字符可能不可解释,并且可能会导致引发异常。When you compile a set of characters with a particular cultural setting and retrieve those same characters with a different cultural setting, the characters might not be interpretable, and can cause an exception to be thrown.

IsolatedStorageFileStream(String, FileMode, FileAccess, FileShare, Int32)

初始化 IsolatedStorageFileStream 类的一个新实例,以便可以使用 path 指定的文件共享模式(指定了 mode),以指定的 access、用指定的文件 share 访问 buffersize 所指定的文件。Initializes a new instance of the IsolatedStorageFileStream class giving access to the file designated by path, in the specified mode, with the specified file access, using the file sharing mode specified by share, with the buffersize specified.

public:
 IsolatedStorageFileStream(System::String ^ path, System::IO::FileMode mode, System::IO::FileAccess access, System::IO::FileShare share, int bufferSize);
public IsolatedStorageFileStream (string path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, int bufferSize);
new System.IO.IsolatedStorage.IsolatedStorageFileStream : string * System.IO.FileMode * System.IO.FileAccess * System.IO.FileShare * int -> System.IO.IsolatedStorage.IsolatedStorageFileStream
Public Sub New (path As String, mode As FileMode, access As FileAccess, share As FileShare, bufferSize As Integer)

参数

path
String

独立存储区内文件的相对路径。The relative path of the file within isolated storage.

mode
FileMode

FileMode 值之一。One of the FileMode values.

access
FileAccess

FileAccess 值的按位组合。A bitwise combination of the FileAccess values.

share
FileShare

FileShare 值的按位组合。A bitwise combination of the FileShare values.

bufferSize
Int32

FileStream 缓冲区的大小。The FileStream buffer size.

例外

path 的格式不正确。The path is badly formed.

pathnullThe path is null.

未找到任何文件,且 mode 设置为 OpenNo file was found and the mode is set to Open.

注解

使用的独立存储区的范围由当前执行程序集的标识和运行它的应用程序域的标识确定。The isolated store that is used is scoped by the current executing assembly's identity and that of the application domain in which it is running. 此存储将在 IsolatedStorageFileStream 对象的生存期内保持打开状态。This store will remain open only for the lifetime of the IsolatedStorageFileStream object. 若要指定不同的独立存储范围,或允许存储保持打开状态(以便可以从其打开多个 IsolatedStorageFileStream 对象),请使用接受 IsolatedStorageFile 对象的构造函数的形式。To specify a different isolated storage scope, or to allow the store to remain open (so multiple IsolatedStorageFileStream objects can be opened from it), use the form of the constructor that accepts an IsolatedStorageFile object.

mode 参数指示是应创建新文件还是使用现有文件。The mode parameter indicates whether a new file should be created or an existing one used. access 参数包括只读、读/写和只写。The access parameter includes read-only, read/write, and write-only.

注意

使用特定的区域性设置编译一组字符,并使用不同的区域性设置检索这些相同的字符时,这些字符可能不可解释,并且可能会导致引发异常。When you compile a set of characters with a particular cultural setting and retrieve those same characters with a different cultural setting, the characters might not be interpretable, and can cause an exception to be thrown.

IsolatedStorageFileStream(String, FileMode, FileAccess, FileShare, IsolatedStorageFile)

初始化 IsolatedStorageFileStream 类的一个新实例,以便可以在 path 指定的 mode 的上下文中,使用 access 指定的文件共享模式,以指定的 share、用指定的文件 IsolatedStorageFile 来访问 isf 所指定的文件。Initializes a new instance of the IsolatedStorageFileStream class giving access to the file designated by path, in the specified mode, with the specified file access, using the file sharing mode specified by share, and in the context of the IsolatedStorageFile specified by isf.

public:
 IsolatedStorageFileStream(System::String ^ path, System::IO::FileMode mode, System::IO::FileAccess access, System::IO::FileShare share, System::IO::IsolatedStorage::IsolatedStorageFile ^ isf);
public IsolatedStorageFileStream (string path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.IO.IsolatedStorage.IsolatedStorageFile isf);
new System.IO.IsolatedStorage.IsolatedStorageFileStream : string * System.IO.FileMode * System.IO.FileAccess * System.IO.FileShare * System.IO.IsolatedStorage.IsolatedStorageFile -> System.IO.IsolatedStorage.IsolatedStorageFileStream
Public Sub New (path As String, mode As FileMode, access As FileAccess, share As FileShare, isf As IsolatedStorageFile)

参数

path
String

独立存储区内文件的相对路径。The relative path of the file within isolated storage.

mode
FileMode

FileMode 值之一。One of the FileMode values.

access
FileAccess

FileAccess 值的按位组合。A bitwise combination of the FileAccess values.

share
FileShare

FileShare 值的按位组合。A bitwise combination of the FileShare values.

例外

path 的格式不正确。The path is badly formed.

pathnullThe path is null.

未找到任何文件,且 mode 设置为 OpenNo file was found and the mode is set to Open.

isf 无配额。isf does not have a quota.

示例

下面的代码示例演示如何使用此构造函数。The following code example demonstrates the use of this constructor. 有关此示例的完整上下文,请参阅 IsolatedStorageFileStream 概述。For the complete context of this example, see the IsolatedStorageFileStream overview.

// This is the stream to which data will be written.
IsolatedStorageFileStream^ source = gcnew IsolatedStorageFileStream( this->userName,FileMode::OpenOrCreate,isoFile );

// This is the stream from which data will be read.
Console::WriteLine( "Is the source file readable?  {0}", (source->CanRead ? (String^)"true" : "false") );
Console::WriteLine( "Creating new IsolatedStorageFileStream for Archive." );

// Open or create a writable file.
IsolatedStorageFileStream^ target = gcnew IsolatedStorageFileStream( String::Concat("Archive\\",this->userName),FileMode::OpenOrCreate,FileAccess::Write,FileShare::Write,isoFile );


IsolatedStorageFileStream source =
    new IsolatedStorageFileStream(this.userName, FileMode.OpenOrCreate,
    isoFile);
// This is the stream from which data will be read.
Console.WriteLine("Is the source file readable? " + (source.CanRead ? "true" : "false"));
Console.WriteLine("Creating new IsolatedStorageFileStream for Archive.");

// Open or create a writable file.
IsolatedStorageFileStream target =
    new IsolatedStorageFileStream("Archive\\ " + this.userName,
    FileMode.OpenOrCreate,
    FileAccess.Write,
    FileShare.Write,
    isoFile);
' Open or create a writable file.
Dim target As New IsolatedStorageFileStream("Archive\ " & Me.userName, _
     FileMode.OpenOrCreate, FileAccess.Write, FileShare.Write, isoFile)

注解

mode 参数指示是应创建新文件还是使用现有文件。The mode parameter indicates whether a new file should be created or an existing one used. access 参数包括只读、读/写和只写。The access parameter includes read-only, read/write, and write-only.

注意

使用特定的区域性设置编译一组字符,并使用不同的区域性设置检索这些相同的字符时,这些字符可能不可解释,并且可能会导致引发异常。When you compile a set of characters with a particular cultural setting and retrieve those same characters with a different cultural setting, the characters might not be interpretable, and can cause an exception to be thrown.

IsolatedStorageFileStream(String, FileMode, FileAccess, FileShare, Int32, IsolatedStorageFile)

初始化 IsolatedStorageFileStream 类的一个新实例,以便可以在 path 指定的 mode 的上下文中,使用 access 指定的文件享模式(指定了 share),以指定的 buffersize、用指定的文件 IsolatedStorageFile 来访问 isf 所指定的文件。Initializes a new instance of the IsolatedStorageFileStream class giving access to the file designated by path, in the specified mode, with the specified file access, using the file sharing mode specified by share, with the buffersize specified, and in the context of the IsolatedStorageFile specified by isf.

public:
 IsolatedStorageFileStream(System::String ^ path, System::IO::FileMode mode, System::IO::FileAccess access, System::IO::FileShare share, int bufferSize, System::IO::IsolatedStorage::IsolatedStorageFile ^ isf);
public IsolatedStorageFileStream (string path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, int bufferSize, System.IO.IsolatedStorage.IsolatedStorageFile isf);
new System.IO.IsolatedStorage.IsolatedStorageFileStream : string * System.IO.FileMode * System.IO.FileAccess * System.IO.FileShare * int * System.IO.IsolatedStorage.IsolatedStorageFile -> System.IO.IsolatedStorage.IsolatedStorageFileStream
Public Sub New (path As String, mode As FileMode, access As FileAccess, share As FileShare, bufferSize As Integer, isf As IsolatedStorageFile)

参数

path
String

独立存储区内文件的相对路径。The relative path of the file within isolated storage.

mode
FileMode

FileMode 值之一。One of the FileMode values.

access
FileAccess

FileAccess 值的按位组合。A bitwise combination of the FileAccess values.

share
FileShare

FileShare 值的按位组合A bitwise combination of the FileShare values

bufferSize
Int32

FileStream 缓冲区的大小。The FileStream buffer size.

例外

path 的格式不正确。The path is badly formed.

pathnullThe path is null.

未找到任何文件,且 mode 设置为 OpenNo file was found and the mode is set to Open.

isf 无配额。isf does not have a quota.

示例

下面的代码示例演示如何使用此构造函数。The following code example demonstrates the use of this constructor. 有关此示例的完整上下文,请参阅 IsolatedStorageFileStream 概述。For the complete context of this example, see the IsolatedStorageFileStream overview.

// Open or create a writable file, no larger than 10k
IsolatedStorageFileStream^ isoStream = gcnew IsolatedStorageFileStream( this->userName,FileMode::OpenOrCreate,FileAccess::Write,FileShare::Write,10240,isoFile );


// Open or create a writable file with a maximum size of 10K.
IsolatedStorageFileStream isoStream =
    new IsolatedStorageFileStream(this.userName,
    FileMode.OpenOrCreate,
    FileAccess.Write,
    FileShare.Write,
    10240,
    isoFile);
' Open or create a writable file with a maximum size of 10K.
Dim isoStream As New IsolatedStorageFileStream(Me.userName, FileMode.OpenOrCreate, _
    FileAccess.Write, FileShare.Write, 10240, isoFile)

注解

mode 参数指示是应创建新文件还是使用现有文件。The mode parameter indicates whether a new file should be created or an existing one used. access 参数包括只读、读/写和只写。The access parameter includes read-only, read/write, and write-only.

注意

使用特定的区域性设置编译一组字符,并使用不同的区域性设置检索这些相同的字符时,这些字符可能不可解释,并且可能会导致引发异常。When you compile a set of characters with a particular cultural setting and retrieve those same characters with a different cultural setting, the characters might not be interpretable, and can cause an exception to be thrown.

适用于