Export (0) Print
Expand All

IsolatedStorageFileStream.Handle Property

Note: This API is now obsolete.

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.

Namespace:  System.IO.IsolatedStorage
Assembly:  mscorlib (in mscorlib.dll)

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

Property Value

Type: System.IntPtr
The file handle for the file that the current IsolatedStorageFileStream object encapsulates.


The Handle property always generates this exception.

For more information, see Handle.

The following code example demonstrates the Handle property.

private bool GetPrefsForUser()

        // Retrieve an IsolatedStorageFile for the current Domain and Assembly.
        IsolatedStorageFile isoFile =
            IsolatedStorageFile.GetStore(IsolatedStorageScope.User |
            IsolatedStorageScope.Assembly |

        IsolatedStorageFileStream isoStream =
            new IsolatedStorageFileStream("substituteUsername",

        // 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. 


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

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

.NET Framework

Supported in: 1.1, 1.0
Obsolete (compiler warning) in 4.5.2
Obsolete (compiler warning) in 4.5.1
Obsolete (compiler warning) in 4.5
Obsolete (compiler warning) in 4
Obsolete (compiler warning) in 3.5
Obsolete (compiler warning) in 3.5 SP1
Obsolete (compiler warning) in 3.0
Obsolete (compiler warning) in 3.0 SP1
Obsolete (compiler warning) in 3.0 SP2
Obsolete (compiler warning) in 2.0
Obsolete (compiler warning) in 2.0 SP1
Obsolete (compiler warning) in 2.0 SP2

.NET Framework Client Profile

Obsolete (compiler warning) in 4
Obsolete (compiler warning) in 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

© 2014 Microsoft