1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
5 using Microsoft
.Win32
.SafeHandles
;
8 using System
.Runtime
.InteropServices
;
10 internal static partial class Interop
12 internal static partial class Kernel32
15 /// WARNING: This method does not implicitly handle long paths. Use CreateFile.
17 [DllImport(Libraries
.Kernel32
, EntryPoint
= "CreateFileW", SetLastError
= true, CharSet
= CharSet
.Unicode
, BestFitMapping
= false)]
18 private static extern SafeFileHandle
CreateFilePrivate(
21 System
.IO
.FileShare dwShareMode
,
22 ref SECURITY_ATTRIBUTES securityAttrs
,
23 System
.IO
.FileMode dwCreationDisposition
,
24 int dwFlagsAndAttributes
,
25 IntPtr hTemplateFile
);
27 internal static SafeFileHandle
CreateFile(
30 System
.IO
.FileShare dwShareMode
,
31 ref SECURITY_ATTRIBUTES securityAttrs
,
32 System
.IO
.FileMode dwCreationDisposition
,
33 int dwFlagsAndAttributes
,
36 lpFileName
= PathInternal
.EnsureExtendedPrefixIfNeeded(lpFileName
);
37 return CreateFilePrivate(lpFileName
, dwDesiredAccess
, dwShareMode
, ref securityAttrs
, dwCreationDisposition
, dwFlagsAndAttributes
, hTemplateFile
);