187 {
188 if (mode == FileMode.Append)
189 {
190 mode = FileMode.OpenOrCreate;
191 }
192 int dwFlagsAndAttributes = (int)(
options | (FileOptions)1048576 | FileOptions.None);
195 {
196 global::Interop.Kernel32.SECURITY_ATTRIBUTES sECURITY_ATTRIBUTES = default(global::Interop.Kernel32.SECURITY_ATTRIBUTES);
197 sECURITY_ATTRIBUTES.nLength = (uint)sizeof(global::Interop.Kernel32.SECURITY_ATTRIBUTES);
198 sECURITY_ATTRIBUTES.bInheritHandle = (((share & FileShare.Inheritable) != 0) ? global::Interop.BOOL.TRUE : global::Interop.BOOL.FALSE);
199 sECURITY_ATTRIBUTES.lpSecurityDescriptor = (
IntPtr)ptr;
200 global::Interop.Kernel32.SECURITY_ATTRIBUTES sECURITY_ATTRIBUTES2 = sECURITY_ATTRIBUTES;
202 {
203 safeFileHandle = global::Interop.Kernel32.
CreateFile(fullPath, (
int)rights, share, &sECURITY_ATTRIBUTES2, mode, dwFlagsAndAttributes,
IntPtr.Zero);
205 }
206 }
207 return safeFileHandle;
208 }
static unsafe SafeFileHandle CreateFile(string fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options)
static void ValidateFileHandle(SafeFileHandle handle, string fullPath)
byte[] GetSecurityDescriptorBinaryForm()