public void CreateFile(out NtHandle handle, out FileStatus fileStatus, string path, AccessMask desiredAccess, FileAttributes fileAttributes, ShareAccess shareAccess, CreateDisposition createDisposition, CreateOptions createOptions, SecurityContext?securityContext) { fileStatus = FileStatus.FILE_DOES_NOT_EXIST; CreateRequest request = new CreateRequest { Name = path, DesiredAccess = desiredAccess, FileAttributes = fileAttributes, ShareAccess = shareAccess, CreateDisposition = createDisposition, CreateOptions = createOptions, ImpersonationLevel = ImpersonationLevel.Impersonation }; SendCommand(request); CreateResponse createResponse = (CreateResponse)WaitForCommand(request.MessageID); createResponse.IsSuccessElseThrow(); handle = createResponse.FileId; fileStatus = ToFileStatus(createResponse.CreateAction); }