System.IO.IsolatedStorage.IsolatedStorageFileStream Class

Assembly: Mscorlib.dll
Namespace: System.IO.IsolatedStorage
Summary
Exposes a file within isolated storage.
C# Syntax:
public class IsolatedStorageFileStream : FileStream
Remarks
Use this class to read, write and create files in isolated storage.

Since this class extends FileStream, you can use an instance of IsolatedStorageFileStream in most situations where a FileStream might otherwise be used, such as to construct a StreamReader or StreamWriter.

See also:
System.IO.IsolatedStorage Namespace

System.IO.IsolatedStorage.IsolatedStorageFileStream Member List:

Public Constructors
ctor #1 Overloaded:
.ctor(string path, FileMode mode)

Initializes a new instance of an IsolatedStorageFileStream object giving access to the file designated by path in the specified mode.
ctor #2 Overloaded:
.ctor(string path, FileMode mode, FileAccess access)

Initializes a new instance of an IsolatedStorageFileStream object giving access to the file designated by path in the specified mode, with the kind of access requested.
ctor #3 Overloaded:
.ctor(string path, FileMode mode, IsolatedStorageFile isf)

ctor #4 Overloaded:
.ctor(string path, FileMode mode, FileAccess access, FileShare share)

Initializes a new instance of an IsolatedStorageFileStream object 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.
ctor #5 Overloaded:
.ctor(string path, FileMode mode, FileAccess access, IsolatedStorageFile isf)

ctor #6 Overloaded:
.ctor(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize)

Initializes a new instance of an IsolatedStorageFileStream object 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.
ctor #7 Overloaded:
.ctor(string path, FileMode mode, FileAccess access, FileShare share, IsolatedStorageFile isf)

ctor #8 Overloaded:
.ctor(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize, IsolatedStorageFile isf)

Initializes a new instance of an IsolatedStorageFileStream object 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 Properties
CanRead Read-only

Overridden:
Gets a Boolean value indicating whether the file can be read.
CanSeek Read-only

Overridden:
Gets a Boolean value indicating whether seek operations are supported.
CanWrite Read-only

Overridden:
Gets a Boolean value indicating whether you can write to the file.
Handle Read-only

Overridden:
Gets the file handle for the file that the current IsolatedStorageFileStream object encapsulates.
IsAsync Read-only

Overridden:
Gets a Boolean value indicating whether the IsolatedStorageFileStream was opened asynchronously or synchronously.
Length Read-only

Overridden:
Gets the length of the IsolatedStorageFileStream.
Name
(inherited from System.IO.FileStream)
Read-only

See base class member description: System.IO.FileStream.Name


Gets the name of the FileStream that was passed to the constructor.
Position Read-write

Overridden:
Gets or sets the current position of this IsolatedStorageFileStream to the specified value.
Public Methods
BeginRead Overridden:
Begins an asynchronous read.
BeginWrite Overridden:
Begins an asynchronous write.
Close Overridden:
Releases resources associated with the IsolatedStorageFileStream.
CreateObjRef
(inherited from System.MarshalByRefObject)
See base class member description: System.MarshalByRefObject.CreateObjRef


Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
EndRead Overridden:
Ends a pending asynchronous read request.
EndWrite Overridden:
Ends an asynchronous write.
Equals
(inherited from System.Object)
See base class member description: System.Object.Equals

Derived from System.Object, the primary base class for all objects.
Flush Overridden:
Updates the file with the current state of the buffer then clears the buffer.
GetHashCode
(inherited from System.Object)
See base class member description: System.Object.GetHashCode

Derived from System.Object, the primary base class for all objects.
GetLifetimeService
(inherited from System.MarshalByRefObject)
See base class member description: System.MarshalByRefObject.GetLifetimeService


Retrieves the current lifetime service object that controls the lifetime policy for this instance.
GetType
(inherited from System.Object)
See base class member description: System.Object.GetType

Derived from System.Object, the primary base class for all objects.
InitializeLifetimeService
(inherited from System.MarshalByRefObject)
See base class member description: System.MarshalByRefObject.InitializeLifetimeService


Obtains a lifetime service object to control the lifetime policy for this instance.
Lock
(inherited from System.IO.FileStream)
See base class member description: System.IO.FileStream.Lock


Prevents access by other processes to all or part of a file.
Read Overridden:
Copies bytes from the current buffered IsolatedStorageFileStream to an array.
ReadByte Overridden:
Reads a single byte from the IsolatedStorageFileStream in isolated storage.
Seek Overridden:
Sets the current position of this IsolatedStorageFileStream to the specified value.
SetLength Overridden:
Sets the length of this IsolatedStorageFileStream to the specified value.
ToString
(inherited from System.Object)
See base class member description: System.Object.ToString

Derived from System.Object, the primary base class for all objects.
Unlock
(inherited from System.IO.FileStream)
See base class member description: System.IO.FileStream.Unlock


Allows access by other processes to all or part of a file that was previously locked.
Write Overridden:
Writes a block of bytes to the IsolatedStorageFileStream using data read from a byte array.
WriteByte Overridden:
Writes a single byte to the IsolatedStorageFileStream.
Protected Methods
CreateWaitHandle
(inherited from System.IO.Stream)
See base class member description: System.IO.Stream.CreateWaitHandle


Allocates a WaitHandle object.
Dispose Overridden:
Releases resources associated with the IsolatedStorageFileStream.
Finalize
(inherited from System.IO.FileStream)
See base class member description: System.IO.FileStream.Finalize


Ensures that resources are freed and other cleanup operations are performed when the garbage collector reclaims the FileStream.
MemberwiseClone
(inherited from System.Object)
See base class member description: System.Object.MemberwiseClone

Derived from System.Object, the primary base class for all objects.

Hierarchy:


System.IO.IsolatedStorage.IsolatedStorageFileStream Member Details

Overloaded ctor #1
Summary
Initializes a new instance of an IsolatedStorageFileStream object giving access to the file designated by path in the specified mode.
C# Syntax:
public IsolatedStorageFileStream(
   string path,
   FileMode mode
);
Parameters:

path

The relative path of the file within isolated storage. The relative path of the file within isolated storage.

mode

One of the FileMode values. One of the FileMode values.

Exceptions
Exception Type Condition
ArgumentException The path is badly formed. -or-

No file was found and the mode is set to Open.

ArgumentNullException The path is null.
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.

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.
.NET Framework Security:
IsolatedStorage code must have isolated storage access

Return to top


Overloaded ctor #2
Summary
Initializes a new instance of an IsolatedStorageFileStream object giving access to the file designated by path in the specified mode, with the kind of access requested.
C# Syntax:
public IsolatedStorageFileStream(
   string path,
   FileMode mode,
   FileAccess access
);
Parameters:

path

The relative path of the file within isolated storage.

mode

One of the FileMode values. One of the FileMode values.

access

A bitwise combination of the FileAccess values. A bitwise combination of the FileAccess values.

Exceptions
Exception Type Condition
ArgumentException The path is badly formed. -or-

No file was found and the mode is set to Open.

ArgumentNullException The path is null.
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.

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.
.NET Framework Security:
IsolatedStorage code must have isolated storage access

Return to top


Overloaded ctor #3
Summary
Initializes a new instance of an IsolatedStorageFileStream object giving access to the file designated by path, in the specified mode, and in the context of the IsolatedStorageFile specified by isf.
C# Syntax:
public IsolatedStorageFileStream(
   string path,
   FileMode mode,
   IsolatedStorageFile isf
);
Parameters:

path

The relative path of the file within isolated storage.

mode

One of the FileMode values. One of the FileMode values.

isf

The IsolatedStorageFile in which to open the IsolatedStorageFileStream. The IsolatedStorageFile in which to open the IsolatedStorageFileStream.

Exceptions
Exception Type Condition
ArgumentException The path is badly formed. -or-

No file was found and the mode is set to Open.

ArgumentNullException The path is null.
Remarks
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.
.NET Framework Security:
IsolatedStorage code must have isolated storage access

Return to top


Overloaded ctor #4
Summary
Initializes a new instance of an IsolatedStorageFileStream object 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# Syntax:
public IsolatedStorageFileStream(
   string path,
   FileMode mode,
   FileAccess access,
   FileShare share
);
Parameters:

path

The relative path of the file within isolated storage.

mode

One of the FileMode values. One of the FileMode values.

access

A bitwise combination of the FileAccess values. A bitwise combination of the FileAccess values.

share

A bitwise combination of the FileShare values. A bitwise combination of the FileShare values.

Exceptions
Exception Type Condition
ArgumentException The path is badly formed. -or-

No file was found and the mode is set to Open.

ArgumentNullException The path is null.
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. 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.
.NET Framework Security:
IsolatedStorage code must have isolated storage access

Return to top


Overloaded ctor #5
Summary
Initializes a new instance of an IsolatedStorageFileStream object 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# Syntax:
public IsolatedStorageFileStream(
   string path,
   FileMode mode,
   FileAccess access,
   IsolatedStorageFile isf
);
Parameters:

path

The relative path of the file within isolated storage.

mode

One of the FileMode values. One of the FileMode values.

access

A bitwise combination of the FileAccess values. A bitwise combination of the FileAccess values.

isf

The IsolatedStorageFile in which to open the IsolatedStorageFileStream.

Exceptions
Exception Type Condition
ArgumentException The path is badly formed. -or-

No file was found and the mode is set to Open.

ArgumentNullException The path is null.
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. 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.
.NET Framework Security:
IsolatedStorage code must have isolated storage access

Return to top


Overloaded ctor #6
Summary
Initializes a new instance of an IsolatedStorageFileStream object 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# Syntax:
public IsolatedStorageFileStream(
   string path,
   FileMode mode,
   FileAccess access,
   FileShare share,
   int bufferSize
);
Parameters:

path

The relative path of the file within isolated storage.

mode

One of the FileMode values. One of the FileMode values.

access

A bitwise combination of the FileAccess values. A bitwise combination of the FileAccess values.

share

A bitwise combination of the FileShare values. A bitwise combination of the FileShare values.

bufferSize

The buffer size.

Exceptions
Exception Type Condition
ArgumentException The path is badly formed. -or-

No file was found and the mode is set to Open.

ArgumentNullException The path is null.
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.

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.
.NET Framework Security:
IsolatedStorage code must have isolated storage access

Return to top


Overloaded ctor #7
Summary
Initializes a new instance of an IsolatedStorageFileStream object 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# Syntax:
public IsolatedStorageFileStream(
   string path,
   FileMode mode,
   FileAccess access,
   FileShare share,
   IsolatedStorageFile isf
);
Parameters:

path

The relative path of the file within isolated storage.

mode

One of the FileMode values. One of the FileMode values.

access

A bitwise combination of the FileAccess values. A bitwise combination of the FileAccess values.

share

A bitwise combination of the FileShare values. A bitwise combination of the FileShare values.

isf

The IsolatedStorageFile in which to open the IsolatedStorageFileStream. The IsolatedStorageFile in which to open the IsolatedStorageFileStream.

Exceptions
Exception Type Condition
ArgumentException The path is badly formed. -or-

No file was found and the mode is set to Open.

ArgumentNullException The path is null.
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. 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.
.NET Framework Security:
IsolatedStorage code must have isolated storage access

Return to top


Overloaded ctor #8
Summary
Initializes a new instance of an IsolatedStorageFileStream object 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# Syntax:
public IsolatedStorageFileStream(
   string path,
   FileMode mode,
   FileAccess access,
   FileShare share,
   int bufferSize,
   IsolatedStorageFile isf
);
Parameters:

path

The relative path of the file within isolated storage.

mode

One of the FileMode values. One of the FileMode values.

access

A bitwise combination of the FileAccess values. A bitwise combination of the FileAccess values.

share

A bitwise combination of the FileShare values

bufferSize

The buffer size.

isf

The IsolatedStorageFile in which to open the IsolatedStorageFileStream. The IsolatedStorageFile in which to open the IsolatedStorageFileStream.

Exceptions
Exception Type Condition
ArgumentException The path is badly formed. -or-

No file was found and the mode is set to Open.

ArgumentNullException The path is null.
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. 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.
.NET Framework Security:
IsolatedStorage code must have isolated storage access

Return to top


Overridden Property: CanRead (read-only)
Summary
Gets a Boolean value indicating whether the file can be read.
C# Syntax:
public override bool CanRead {get;}
Remarks
Use this property to determine whether the IsolatedStorageFileStream can be read.

Return to top


Overridden Property: CanSeek (read-only)
Summary
Gets a Boolean value indicating whether seek operations are supported.
C# Syntax:
public override bool CanSeek {get;}
Remarks
Use this property to determine whether the IsolatedStorageFileStream supports seek operations.

Return to top


Overridden Property: CanWrite (read-only)
Summary
Gets a Boolean value indicating whether you can write to the file.
C# Syntax:
public override bool CanWrite {get;}
Remarks
Use this property to determine whether the IsolatedStorageFileStream can be written.

Return to top


Overridden Property: Handle (read-only)
Summary
Gets the file handle for the file that the current IsolatedStorageFileStream object encapsulates.
C# Syntax:
public override IntPtr Handle {get;}
Remarks
For more information, see FileStream.Handle.
.NET Framework Security:
SecurityPermission for the ability to access unmanaged code. Associated enumeration: SecurityPermissionFlag.UnmanagedCode

Return to top


Overridden Property: IsAsync (read-only)
Summary
Gets a Boolean value indicating whether the IsolatedStorageFileStream was opened asynchronously or synchronously.
C# Syntax:
public override bool IsAsync {get;}
Remarks
Use this parameter to determine whether the IsolatedStorageFileStream supports asynchronous access.

Return to top


Overridden Property: Length (read-only)
Summary
Gets the length of the IsolatedStorageFileStream.
C# Syntax:
public override long Length {get;}
Remarks
Length represents the number of bytes currently in the file. It is not affected by isolated storage quota.

Return to top


Property: Name (read-only)
Inherited
See base class member description: System.IO.FileStream.Name

Summary
Gets the name of the FileStream that was passed to the constructor.
C# Syntax:
public string Name {get;}
.NET Framework Security:
FileIOPermission for access to the path. Associated enumeration: FileIOPermissionAccess.PathDiscovery

Return to top


Overridden Property: Position (read-write)
Summary
Gets or sets the current position of this IsolatedStorageFileStream to the specified value.
C# Syntax:
public override long Position {get; set;}
Exceptions
Exception Type Condition
ArgumentOutOfRangeException The position cannot be set to a negative number.
Remarks
Setting this property works when the IsolatedStorageFileStream.CanSeek property is true.

Return to top


Overridden Method: BeginRead(
   byte[] buffer,
   int offset,
   int numBytes,
   AsyncCallback userCallback,
   object stateObject
)
Summary
Begins an asynchronous read.
C# Syntax:
public override IAsyncResult BeginRead(
   byte[] buffer,
   int offset,
   int numBytes,
   AsyncCallback userCallback,
   object stateObject
);
Parameters:

buffer

The buffer into which to read data.

offset

The byte offset in array at which to begin reading.

numBytes

The maximum number of bytes to read.

userCallback

The method to be called when the asynchronous read operation is completed. This parameter is optional.

stateObject

The status of the asynchronous read.

Return Value:
An IAsyncResult that represents the asynchronous read, which is possibly still pending. This IAsyncResult must be passed to this stream's IsolatedStorageFileStream.EndRead method to determine how many bytes were read. This can be done either by the same code that called IsolatedStorageFileStream.BeginRead or in a callback passed to IsolatedStorageFileStream.BeginRead.
Exceptions
Exception Type Condition
IOException An asynchronous read was attempted past the end of the file.
Remarks
The current position in the stream is updated when you issue the asynchronous read or write, not when the I/O operation completes.

You must call Stream.EndRead with this IAsyncResult to find out how many bytes were read.

Return to top


Overridden Method: BeginWrite(
   byte[] buffer,
   int offset,
   int numBytes,
   AsyncCallback userCallback,
   object stateObject
)
Summary
Begins an asynchronous write.
C# Syntax:
public override IAsyncResult BeginWrite(
   byte[] buffer,
   int offset,
   int numBytes,
   AsyncCallback userCallback,
   object stateObject
);
Parameters:

buffer

The buffer to which to write data.

offset

The byte offset in array at which to begin writing.

numBytes

The maximum number of bytes to write.

userCallback

The method to be called when the asynchronous write operation is completed. This parameter is optional.

stateObject

The status of the asynchronous write.

Return Value:
An IAsyncResult that represents the asynchronous write, which is possibly still pending. This IAsyncResult must be passed to this stream's Stream.EndWrite method to ensure that the write is complete, then frees resources appropriately. This can be done either by the same code that called BeginWrite or in a callback passed to BeginWrite.
Exceptions
Exception Type Condition
IOException An asynchronous write was attempted past the end of the file.
Remarks
If a IsolatedStorageFileStream is writable, writing at the end of the stream expands the stream.

The current position in the stream is updated when you issue the asynchronous read or write, not when the I/O operation completes.

You must call Stream.EndWrite with the IAsyncResult that this method returns to find out how many bytes were written.

Return to top


Overridden Method: Close()
Summary
Releases resources associated with the IsolatedStorageFileStream.
C# Syntax:
public override void Close();
Remarks
Any data previously written to the buffer is copied to the file before the file stream is closed, so it is not necessary to call IsolatedStorageFileStream.Flush before invoking IsolatedStorageFileStream.Close.

Following a call to IsolatedStorageFileStream.Close, any operations on the file stream might raise exceptions. After IsolatedStorageFileStream.Close has been called once, it does nothing if called again. The Object.Finalize method invokes IsolatedStorageFileStream.Close so the file stream is closed before the garbage collector finalizes the object.

IsolatedStorageFileStream objects require an IsolatedStorageFile that determines the storage context for the files accessed. For streams opened without passing an IsolatedStorageFile object, a default IsolatedStorageFile is created for the executing assembly and then closed during the call to IsolatedStorageFileStream.Close.



Note The Close method calls IsolatedStorageFileStream.Dispose with disposing set to true to release its resources, then calls GC.SuppressFinalize to suppress finalization of this object by the garbage collector.

Return to top


Method: CreateObjRef(
   Type requestedType
)
Inherited
See base class member description: System.MarshalByRefObject.CreateObjRef

Summary
Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
C# Syntax:
public virtual ObjRef CreateObjRef(
   Type requestedType
);
Parameters:

requestedType

The Type of the object that the new ObjRef will reference.

Return Value:
Information required to generate a proxy.
Exceptions
Exception Type Condition
RemotingException This instance is not a valid remoting object.

Return to top


Method: CreateWaitHandle()
Inherited
See base class member description: System.IO.Stream.CreateWaitHandle

Summary
Allocates a WaitHandle object.
C# Syntax:
protected virtual WaitHandle CreateWaitHandle();
Return Value:
A reference to the allocated WaitHandle.
Remarks
When called for the first time, the current method creates a WaitHandle object and returns it. On subsequent calls, the CreateWaitHandle returns a reference to the same wait handle.

Use this method if you implement the asynchronous methods and require a way of blocking in Stream.EndRead or Stream.EndWrite until the asynchronous operation is complete.

Return to top


Overridden Method: Dispose(
   bool disposing
)
Summary
Releases resources associated with the IsolatedStorageFileStream.
C# Syntax:
protected override void Dispose(
   bool disposing
);
Parameters:

disposing

A value that indicates all associated resources should be closed.

Remarks
Call Dispose when you are finished using the IsolatedStorageFileStream. The Dispose method leaves the IsolatedStorageFileStream in an unusable state. After calling Dispose, you must release all references to the IsolatedStorageFileStream so the memory it was occupying can be reclaimed by garbage collection.

Note Always call Dispose before you release your last reference to the IsolatedStorageFileStream. Otherwise, the resources the IsolatedStorageFileStream is using will not be freed until garbage collection calls the IsolatedStorageFileStream object's destructor.

Return to top


Overridden Method: EndRead(
   IAsyncResult asyncResult
)
Summary
Ends a pending asynchronous read request.
C# Syntax:
public override int EndRead(
   IAsyncResult asyncResult
);
Parameters:

asyncResult

The pending asynchronous request.

Return Value:
The number of bytes read from the stream, between zero and the number of requested bytes. Streams will only return zero at the end of the stream. Otherwise, they will block until at least one byte is available.
Exceptions
Exception Type Condition
ArgumentNullException The asyncResult is null.
Remarks
EndRead must be called exactly once on every IAsyncResult from IsolatedStorageFileStream.BeginRead, and calling EndRead is the only way to know how many bytes were read from the Stream.EndRead will block until the I/O operation has completed.

Return to top


Overridden Method: EndWrite(
   IAsyncResult asyncResult
)
Summary
Ends an asynchronous write.
C# Syntax:
public override void EndWrite(
   IAsyncResult asyncResult
);
Parameters:

asyncResult

The pending asynchronous I/O request to end.

Exceptions
Exception Type Condition
ArgumentNullException The asyncResult parameter is null.
Remarks
EndWrite must be called exactly once on every IAsyncResult from IsolatedStorageFileStream.BeginWrite.

EndWrite will block until the I/O operation has completed.

Return to top


Method: Equals(
   object obj
)
Inherited
See base class member description: System.Object.Equals
C# Syntax:
public virtual bool Equals(
   object obj
);

For more information on members inherited from System.Object click on the link above.

Return to top


Method: Finalize()
Inherited
See base class member description: System.IO.FileStream.Finalize

Summary
Ensures that resources are freed and other cleanup operations are performed when the garbage collector reclaims the FileStream.
C# Syntax:
~FileStream();
Exceptions
Exception Type Condition
IOException The handle for the file is invalid.
Remarks
The garbage collector calls Finalize when the current object is ready to be finalized.Finalize closes the FileStream.

Return to top


Overridden Method: Flush()
Summary
Updates the file with the current state of the buffer then clears the buffer.
C# Syntax:
public override void Flush();
Remarks
Since a buffer can be used for either reading or writing, but not both simultaneously, Flush performs two functions. First, any data previously written to the buffer is copied to the file and the buffer is cleared. Second, if IsolatedStorageFileStream.CanSeek is true and data was previously copied from the file to the buffer for reading, the current position within the file is decremented by the number of unread bytes in the buffer. The buffer is then cleared.

Return to top


Method: GetHashCode()
Inherited
See base class member description: System.Object.GetHashCode
C# Syntax:
public virtual int GetHashCode();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: GetLifetimeService()
Inherited
See base class member description: System.MarshalByRefObject.GetLifetimeService

Summary
Retrieves the current lifetime service object that controls the lifetime policy for this instance.
C# Syntax:
public object GetLifetimeService();
Return Value:
An object of type ILease used to control the lifetime policy for this instance.
Remarks
For more information about lifetime services, see the LifetimeServices class.

Return to top


Method: GetType()
Inherited
See base class member description: System.Object.GetType
C# Syntax:
public Type GetType();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: InitializeLifetimeService()
Inherited
See base class member description: System.MarshalByRefObject.InitializeLifetimeService

Summary
Obtains a lifetime service object to control the lifetime policy for this instance.
C# Syntax:
public virtual object InitializeLifetimeService();
Return Value:
An object of type ILease used to control the lifetime policy for this instance. This is the current lifetime service object for this instance if one exists; otherwise, a new lifetime service object initialized to the value of the LifetimeServices.LeaseManagerPollTime property.
Remarks
For more information about lifetime services, see the LifetimeServices class.
Example
The following code example demonstrates creating a lease.
 public class MyClass : MarshalByRefObject
 {
   public override Object InitializeLifetimeService()
   {
     ILease lease = (ILease)base.InitializeLifetimeService();
     if (lease.CurrentState == LeaseState.Initial)
     {
          lease.InitialLeaseTime = TimeSpan.FromMinutes(1);
          lease.SponsorshipTimeout = TimeSpan.FromMinutes(2);
           lease.RenewOnCallTime = TimeSpan.FromSeconds(2);
     }
       return lease;
   }
 }

    

Return to top


Method: Lock(
   long position,
   long length
)
Inherited
See base class member description: System.IO.FileStream.Lock

Summary
Prevents access by other processes to all or part of a file.
C# Syntax:
public virtual void Lock(
   long position,
   long length
);
Parameters:

position

The beginning of the range to lock.

length

The range to be locked.

Exceptions
Exception Type Condition
ArgumentOutOfRangeException position or length is negative.
IOException An I/O error occurs, such as the file being closed or its handle being invalid.

Return to top


Method: MemberwiseClone()
Inherited
See base class member description: System.Object.MemberwiseClone
C# Syntax:
protected object MemberwiseClone();

For more information on members inherited from System.Object click on the link above.

Return to top


Overridden Method: Read(
   byte[] buffer,
   int offset,
   int count
)
Summary
Copies bytes from the current buffered IsolatedStorageFileStream to an array.
C# Syntax:
public override int Read(
   byte[] buffer,
   int offset,
   int count
);
Parameters:

buffer

The buffer to read.

offset

The offset in the buffer at which to begin writing.

count

The maximum number of bytes to read.

Return Value:
The total number of bytes read into the buffer. This can be less than the number of bytes requested if that many bytes are not currently available, or zero if the end of the stream is reached.
Remarks
The buffer parameter can be an instance of the Buffer class, or an array of one of the following types: Byte, SByte, Char, Int16, Int32, Int64, UInt16, UInt32, UInt64, Single, or Double. The offset parameter gives the offset of the byte in buffer at which to begin writing (index in the buffer), and the count parameter gives the maximum number of bytes that will be read from this stream. The returned value is the actual number of bytes read, or zero if the end of the stream is reached. If the read operation is successful, the current position of the stream is advanced by the number of bytes read. If an exception occurs, the current position of the stream is unchanged.

The Read method treats the buffer parameter as a block of bytes, regardless of its actual type. Likewise, the offset and count parameters are always specified in bytes. For buffer parameters other than byte arrays, this means that an element index must be multiplied by the element size in bytes to form a correct value for offset or count.

The Read method will return zero only if the end of the stream is reached. In all other cases, Read always reads at least one byte from the stream before returning. If no data is available from the IsolatedStorageFileStream upon a call to Read, the method will block until at least one byte of data can be returned.

Return to top


Overridden Method: ReadByte()
Summary
Reads a single byte from the IsolatedStorageFileStream in isolated storage.
C# Syntax:
public override int ReadByte();
Return Value:
The 8-bit unsigned integer value read from the isolated storage file.

Return to top


Overridden Method: Seek(
   long offset,
   SeekOrigin origin
)
Summary
Sets the current position of this IsolatedStorageFileStream to the specified value.
C# Syntax:
public override long Seek(long offset, Seek(
   long offset,
   SeekOrigin origin
);
Parameters:

offset

The new position of the IsolatedStorageFileStream.

origin

One of the SeekOrigin values.

Return Value:
The new position in the IsolatedStorageFileStream.
Exceptions
Exception Type Condition
ArgumentException The origin must be one of the SeekOrigin values.
Remarks
Some IsolatedStorageFileStream objects support positioning beyond the length of the stream, others will throw an exception in this case.

Return to top


Overridden Method: SetLength(
   long value
)
Summary
Sets the length of this IsolatedStorageFileStream to the specified value.
C# Syntax:
public override void SetLength(
   long value
);
Parameters:

value

The new length of the IsolatedStorageFileStream.

Remarks
If the specified value is less than the current length of the IsolatedStorageFileStream, the stream is truncated. If the specified value is larger than the current length of the stream, the stream is expanded. If the stream is expanded, the contents of the stream between the old and the new length are undefined. In order to use this method, an IsolatedStorageFileStream must support both writing and seeking.

Return to top


Method: ToString()
Inherited
See base class member description: System.Object.ToString
C# Syntax:
public virtual string ToString();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: Unlock(
   long position,
   long length
)
Inherited
See base class member description: System.IO.FileStream.Unlock

Summary
Allows access by other processes to all or part of a file that was previously locked.
C# Syntax:
public virtual void Unlock(
   long position,
   long length
);
Parameters:

position

The beginning of the range to unlock.

length

The range to be unlocked.

Exceptions
Exception Type Condition
ArgumentOutOfRangeException position or length is negative.

Return to top


Overridden Method: Write(
   byte[] buffer,
   int offset,
   int count
)
Summary
Writes a block of bytes to the IsolatedStorageFileStream using data read from a byte array.
C# Syntax:
public override void Write(
   byte[] buffer,
   int offset,
   int count
);
Parameters:

buffer

The buffer to write.

offset

The byte offset in buffer from which to begin.

count

The maximum number of bytes to write.

Remarks
The offset parameter gives the offset of the byte in the buffer at which to begin reading, and the count parameter gives the number of bytes that will be written to this IsolatedStorageFileStream. If the write operation is successful, the current position of the IsolatedStorageFileStream is advanced by the number of bytes written. If an exception occurs, the current position of the IsolatedStorageFileStream is unchanged.

Return to top


Overridden Method: WriteByte(
   byte value
)
Summary
Writes a single byte to the IsolatedStorageFileStream.
C# Syntax:
public override void WriteByte(
   byte value
);
Parameters:

value

The byte value to write to the isolated storage file.

Return to top


Top of page

Copyright (c) 2002 Microsoft Corporation. All rights reserved.