IsolatedStorageFileStream Constructors

Definition

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 path in the specified mode.

IsolatedStorageFileStream(String, FileMode, FileAccess)

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)

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)

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)

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)

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)

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)

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)

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.

C#
public IsolatedStorageFileStream(string path, System.IO.FileMode mode);

Parameters

path
String

The relative path of the file within isolated storage.

mode
FileMode

One of the FileMode values.

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

.NET 10 and other versions
Product Versions
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

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.

C#
public IsolatedStorageFileStream(string path, System.IO.FileMode mode, System.IO.FileAccess access);

Parameters

path
String

The relative path of the file within isolated storage.

mode
FileMode

One of the FileMode values.

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

.NET 10 and other versions
Product Versions
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

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.

C#
public IsolatedStorageFileStream(string path, System.IO.FileMode mode, System.IO.IsolatedStorage.IsolatedStorageFile isf);
C#
public IsolatedStorageFileStream(string path, System.IO.FileMode mode, System.IO.IsolatedStorage.IsolatedStorageFile? isf);

Parameters

path
String

The relative path of the file within isolated storage.

mode
FileMode

One of the FileMode values.

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.

C#

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);

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

.NET 10 and other versions
Product Versions
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1
UWP 10.0

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.

C#
public IsolatedStorageFileStream(string path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share);

Parameters

path
String

The relative path of the file within isolated storage.

mode
FileMode

One of the FileMode values.

access
FileAccess

A bitwise combination of the FileAccess values.

share
FileShare

A bitwise combination of the FileShare 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.

C#

// 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);

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

.NET 10 and other versions
Product Versions
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

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.

C#
public IsolatedStorageFileStream(string path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.IsolatedStorage.IsolatedStorageFile isf);
C#
public IsolatedStorageFileStream(string path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.IsolatedStorage.IsolatedStorageFile? isf);

Parameters

path
String

The relative path of the file within isolated storage.

mode
FileMode

One of the FileMode values.

access
FileAccess

A bitwise combination of the FileAccess values.

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.

C#
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;

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

.NET 10 and other versions
Product Versions
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1
UWP 10.0

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.

C#
public IsolatedStorageFileStream(string path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, int bufferSize);

Parameters

path
String

The relative path of the file within isolated storage.

mode
FileMode

One of the FileMode values.

access
FileAccess

A bitwise combination of the FileAccess values.

share
FileShare

A bitwise combination of the FileShare 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

.NET 10 and other versions
Product Versions
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

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.

C#
public IsolatedStorageFileStream(string path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.IO.IsolatedStorage.IsolatedStorageFile isf);
C#
public IsolatedStorageFileStream(string path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.IO.IsolatedStorage.IsolatedStorageFile? isf);

Parameters

path
String

The relative path of the file within isolated storage.

mode
FileMode

One of the FileMode values.

access
FileAccess

A bitwise combination of the FileAccess values.

share
FileShare

A bitwise combination of the FileShare values.

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.

C#

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);

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

.NET 10 and other versions
Product Versions
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1
UWP 10.0

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.

C#
public IsolatedStorageFileStream(string path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, int bufferSize, System.IO.IsolatedStorage.IsolatedStorageFile? isf);
C#
public IsolatedStorageFileStream(string path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, int bufferSize, System.IO.IsolatedStorage.IsolatedStorageFile isf);

Parameters

path
String

The relative path of the file within isolated storage.

mode
FileMode

One of the FileMode values.

access
FileAccess

A bitwise combination of the FileAccess values.

share
FileShare

A bitwise combination of the FileShare 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.

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.

C#

// 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);

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

.NET 10 and other versions
Product Versions
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1