SafeFileHandle Constructor (IntPtr, Boolean)

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Initializes a new instance of the SafeFileHandle class.

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

public:
SafeFileHandle(
	IntPtr preexistingHandle,
	bool ownsHandle
)

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: