SafeFileHandle Constructor (IntPtr, Boolean)

 

Initializes a new instance of the SafeFileHandle class.

Namespace:   Microsoft.Win32.SafeHandles
Assembly:  mscorlib (in mscorlib.dll)

new : 
        preexistingHandle:nativeint *
        ownsHandle:bool -> SafeFileHandle

Parameters

preexistingHandle
Type: System.IntPtr

An IntPtr object that represents the pre-existing handle to use.

ownsHandle
Type: System.Boolean

true to reliably release the handle during the finalization phase; false to prevent reliable release (not recommended).

The following example demonstrates how to open a file by using the SafeFileHandle class and the unmanaged CreateFile function.

No code example is currently available or this language may not be supported.

SecurityCriticalAttribute

requires full trust for the immediate caller. This member cannot be used by partially trusted or transparent code.

Universal Windows Platform
Available since 10
.NET Framework
Available since 2.0
Return to top
Show: