This documentation is archived and is not being maintained.

IsolatedStorageFileStream.CanRead Property

Gets a Boolean value indicating whether the file can be read.

[Visual Basic]
Overrides Public ReadOnly Property CanRead As Boolean
[C#]
public override bool CanRead {get;}
[C++]
public: __property bool get_CanRead();
[JScript]
public override function get CanRead() : Boolean;

Property Value

true if an IsolatedStorageFileStream can be read; otherwise, false.

Remarks

Use this property to determine whether the IsolatedStorageFileStream can be read.

Example

[Visual Basic, C#, C++] The following code example demonstrates how you could use the CanRead property, as a check to see whether a stream can be read before calling the Read or BeginRead methods. For the complete context of this example, see the IsolatedStorageFileStream overview.

[Visual Basic] 
' Open or create a writable file.
Dim target As New IsolatedStorageFileStream("Archive\ " & Me.userName, _
     FileMode.OpenOrCreate, FileAccess.Write, FileShare.Write, isoFile)

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

[C++] 
// This is the stream to which data will be written.
IsolatedStorageFileStream* source =
   new IsolatedStorageFileStream(this->userName,FileMode::OpenOrCreate,
   isoFile);
// This is the stream from which data will be read.
Console::WriteLine(S"Is the source file readable?  {0}", (source->CanRead ? S"true" : S"false"));
Console::WriteLine(S"Creating new IsolatedStorageFileStream for Archive.");
// Open or create a writable file.
IsolatedStorageFileStream* target =
   new IsolatedStorageFileStream((S"Archive\\ {0}", this->userName),
   FileMode::OpenOrCreate,
   FileAccess::Write,
   FileShare::Write,
   isoFile);

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

IsolatedStorageFileStream Class | IsolatedStorageFileStream Members | System.IO.IsolatedStorage Namespace

Show: