IsolatedStorageFileStream.Handle Property

Definition

Caution

IsolatedStorageFileStream.Handle has been deprecated. Use IsolatedStorageFileStream's SafeFileHandle property instead.

Caution

This property has been deprecated. Please use IsolatedStorageFileStream's SafeFileHandle property instead. https://go.microsoft.com/fwlink/?linkid=14202

Caution

This property has been deprecated. Please use IsolatedStorageFileStream's SafeFileHandle property instead. http://go.microsoft.com/fwlink/?linkid=14202

Gets the file handle for the file that the current IsolatedStorageFileStream object encapsulates. Accessing this property is not permitted on an IsolatedStorageFileStream object, and throws an IsolatedStorageException.

C#
[System.Obsolete("IsolatedStorageFileStream.Handle has been deprecated. Use IsolatedStorageFileStream's SafeFileHandle property instead.")]
public override IntPtr Handle { get; }
C#
[System.Obsolete("This property has been deprecated.  Please use IsolatedStorageFileStream's SafeFileHandle property instead.  https://go.microsoft.com/fwlink/?linkid=14202")]
public override IntPtr Handle { get; }
C#
[System.Obsolete("This property has been deprecated.  Please use IsolatedStorageFileStream's SafeFileHandle property instead.  http://go.microsoft.com/fwlink/?linkid=14202")]
public override IntPtr Handle { get; }
C#
public override IntPtr Handle { get; }
C#
[System.Obsolete("This property has been deprecated.  Please use IsolatedStorageFileStream's SafeFileHandle property instead.  http://go.microsoft.com/fwlink/?linkid=14202")]
public override IntPtr Handle { [System.Security.SecurityCritical] get; }

Property Value

IntPtr

The file handle for the file that the current IsolatedStorageFileStream object encapsulates.

Attributes

Exceptions

The Handle property always generates this exception.

Examples

The following code example demonstrates the Handle property.

C#
private bool GetPrefsForUser()
{
    try
    {

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

        // The code executes to this point only if a file corresponding to the username exists.
        // Though you can perform operations on the stream, you cannot get a handle to the file.

        try
        {

            SafeFileHandle aFileHandle = isoStream.SafeFileHandle;
            Console.WriteLine("A pointer to a file handle has been obtained. "
                + aFileHandle.ToString() + " "
                + aFileHandle.GetHashCode());
        }

        catch (Exception e)
        {
            // Handle the exception.
            Console.WriteLine("Expected exception");
            Console.WriteLine(e);
        }

        StreamReader reader = new StreamReader(isoStream);
        // Read the data.
        this.NewsUrl = reader.ReadLine();
        this.SportsUrl = reader.ReadLine();
        reader.Close();
        isoFile.Close();
        return false;
    }
    catch (System.IO.FileNotFoundException)
    {
        // Expected exception if a file cannot be found. This indicates that we have a new user.
        return true;
    }
}

Remarks

For more information, see Handle.

Applies to

Product Versions (Obsolete)
.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)