IsolatedStorageFileStream Constructors
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Initializes a new instance of the IsolatedStorageFileStream class. The only way to open an IsolatedStorageFileStream is by using one of its constructors.
Overloads
IsolatedStorageFileStream(String, FileMode) |
Initializes a new instance of an IsolatedStorageFileStream object giving access to the file designated by |
IsolatedStorageFileStream(String, FileMode, FileAccess) |
Initializes a new instance of the IsolatedStorageFileStream class giving access to the file designated by |
IsolatedStorageFileStream(String, FileMode, IsolatedStorageFile) |
Initializes a new instance of the IsolatedStorageFileStream class giving access to the file designated by |
IsolatedStorageFileStream(String, FileMode, FileAccess, FileShare) |
Initializes a new instance of the IsolatedStorageFileStream class giving access to the file designated by |
IsolatedStorageFileStream(String, FileMode, FileAccess, IsolatedStorageFile) |
Initializes a new instance of the IsolatedStorageFileStream class giving access to the file designated by |
IsolatedStorageFileStream(String, FileMode, FileAccess, FileShare, Int32) |
Initializes a new instance of the IsolatedStorageFileStream class giving access to the file designated by |
IsolatedStorageFileStream(String, FileMode, FileAccess, FileShare, IsolatedStorageFile) |
Initializes a new instance of the IsolatedStorageFileStream class giving access to the file designated by |
IsolatedStorageFileStream(String, FileMode, FileAccess, FileShare, Int32, IsolatedStorageFile) |
Initializes a new instance of the IsolatedStorageFileStream class giving access to the file designated by |
IsolatedStorageFileStream(String, FileMode)
- Source:
- IsolatedStorageFileStream.cs
- Source:
- IsolatedStorageFileStream.cs
- Source:
- IsolatedStorageFileStream.cs
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)
Parameters
- path
- String
The relative path of the file within isolated storage.
Exceptions
The path
is badly formed.
The path
is null
.
The directory in path
does not exist.
No file was found and the mode
is set to Open
Remarks
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. This store will remain open only for the lifetime of the IsolatedStorageFileStream object. 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.
The mode
parameter indicates whether a new file should be created, an existing one used, and so on.
Caution
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.
Applies to
IsolatedStorageFileStream(String, FileMode, FileAccess)
- Source:
- IsolatedStorageFileStream.cs
- Source:
- IsolatedStorageFileStream.cs
- Source:
- IsolatedStorageFileStream.cs
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)
Parameters
- path
- String
The relative path of the file within isolated storage.
- access
- FileAccess
A bitwise combination of the FileAccess values.
Exceptions
The path
is badly formed.
The path
is null
.
No file was found and the mode
is set to Open.
Remarks
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. This store will remain open only for the lifetime of the IsolatedStorageFileStream object. 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.
The mode
parameter indicates whether a new file should be created or an existing one used. The access
parameter includes read-only, read/write, and write-only.
Caution
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.
Applies to
IsolatedStorageFileStream(String, FileMode, IsolatedStorageFile)
- Source:
- IsolatedStorageFileStream.cs
- Source:
- IsolatedStorageFileStream.cs
- Source:
- IsolatedStorageFileStream.cs
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);
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)
Parameters
- path
- String
The relative path of the file within isolated storage.
The IsolatedStorageFile in which to open the IsolatedStorageFileStream.
Exceptions
The path
is badly formed.
The path
is null
.
No file was found and the mode
is set to Open.
isf
does not have a quota.
Examples
The following code example demonstrates the use of this constructor. 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)
Remarks
The mode
parameter indicates whether a new file should be created, an existing one used, and so on.
Caution
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.
Applies to
IsolatedStorageFileStream(String, FileMode, FileAccess, FileShare)
- Source:
- IsolatedStorageFileStream.cs
- Source:
- IsolatedStorageFileStream.cs
- Source:
- IsolatedStorageFileStream.cs
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)
Parameters
- path
- String
The relative path of the file within isolated storage.
- access
- FileAccess
A bitwise combination of the FileAccess values.
Exceptions
The path
is badly formed.
The path
is null
.
No file was found and the mode
is set to Open.
Examples
The following code example demonstrates the use of this constructor. 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)
Remarks
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. This store will remain open only for the lifetime of the IsolatedStorageFileStream object. 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.
Caution
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.
Applies to
IsolatedStorageFileStream(String, FileMode, FileAccess, IsolatedStorageFile)
- Source:
- IsolatedStorageFileStream.cs
- Source:
- IsolatedStorageFileStream.cs
- Source:
- IsolatedStorageFileStream.cs
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);
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)
Parameters
- path
- String
The relative path of the file within isolated storage.
- access
- FileAccess
A bitwise combination of the FileAccess values.
The IsolatedStorageFile in which to open the IsolatedStorageFileStream.
Exceptions
The path
is badly formed.
The path
is null
.
The isolated store is closed.
No file was found and the mode
is set to Open.
isf
does not have a quota.
Examples
The following code example demonstrates the use of this constructor. 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
Remarks
The mode
parameter indicates whether a new file should be created or an existing one used. The access
parameter includes read-only, read/write, and write-only.
Caution
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.
Applies to
IsolatedStorageFileStream(String, FileMode, FileAccess, FileShare, Int32)
- Source:
- IsolatedStorageFileStream.cs
- Source:
- IsolatedStorageFileStream.cs
- Source:
- IsolatedStorageFileStream.cs
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)
Parameters
- path
- String
The relative path of the file within isolated storage.
- access
- FileAccess
A bitwise combination of the FileAccess values.
- bufferSize
- Int32
The FileStream buffer size.
Exceptions
The path
is badly formed.
The path
is null
.
No file was found and the mode
is set to Open.
Remarks
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. This store will remain open only for the lifetime of the IsolatedStorageFileStream object. 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.
The mode
parameter indicates whether a new file should be created or an existing one used. The access
parameter includes read-only, read/write, and write-only.
Caution
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.
Applies to
IsolatedStorageFileStream(String, FileMode, FileAccess, FileShare, IsolatedStorageFile)
- Source:
- IsolatedStorageFileStream.cs
- Source:
- IsolatedStorageFileStream.cs
- Source:
- IsolatedStorageFileStream.cs
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);
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)
Parameters
- path
- String
The relative path of the file within isolated storage.
- access
- FileAccess
A bitwise combination of the FileAccess values.
The IsolatedStorageFile in which to open the IsolatedStorageFileStream.
Exceptions
The path
is badly formed.
The path
is null
.
No file was found and the mode
is set to Open.
isf
does not have a quota.
Examples
The following code example demonstrates the use of this constructor. 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)
Remarks
The mode
parameter indicates whether a new file should be created or an existing one used. The access
parameter includes read-only, read/write, and write-only.
Caution
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.
Applies to
IsolatedStorageFileStream(String, FileMode, FileAccess, FileShare, Int32, IsolatedStorageFile)
- Source:
- IsolatedStorageFileStream.cs
- Source:
- IsolatedStorageFileStream.cs
- Source:
- IsolatedStorageFileStream.cs
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);
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)
Parameters
- path
- String
The relative path of the file within isolated storage.
- access
- FileAccess
A bitwise combination of the FileAccess values.
- bufferSize
- Int32
The FileStream buffer size.
The IsolatedStorageFile in which to open the IsolatedStorageFileStream.
Exceptions
The path
is badly formed.
The path
is null
.
No file was found and the mode
is set to Open.
isf
does not have a quota.
Examples
The following code example demonstrates the use of this constructor. 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)
Remarks
The mode
parameter indicates whether a new file should be created or an existing one used. The access
parameter includes read-only, read/write, and write-only.
Caution
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.