I am trying to use the CreateFile function to access directory information. However, I get a win32 error code of 5, which means denied access. Please inform.
CreateFile(path, GENERIC_READ, FILE_SHARE_READ, IntPtr.Zero, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, IntPtr.Zero);
This is a call, and as indicated in the documentation, FILE_FLAG_BACKUP_SEMANTICS is used. Importing the DLL seems to work fine and looks like this:
[DllImport("kernel32.dll", SetLastError = true)]
public static extern IntPtr CreateFile(string filename,
uint desiredAccess,
uint sharedMode,
IntPtr securityAttributes,
uint creationDisposition,
uint flagsAndAttributes,
IntPtr templateFile);
Update: I need to get a directory descriptor so that I can use GetFileInformationByHandle () and retrieve a unique identifier. This method currently works with files; it does not work with directories at present.
: X : , - , . , ..NET - , , win32