How do I open a directory with CreateFile in C# to examine deleted entries?

前端 未结 3 866
甜味超标
甜味超标 2021-01-01 03:00

How do I open a directory with CreateFile in C# to examine entries of deleted files? Or is it now impossible? I remember way back when being able to open a directory on an

3条回答
  •  情深已故
    2021-01-01 03:28

    I'm not sure what you mean by examining deleted directories, but you should be able to get a handle to a directory by passing the FILE_FLAG_BACKUP_SEMANTICS flag into CreateFile and by making sure to specify OPEN_EXISTING for the creation disposition. From the MSDN article on CreateFile:

    To open a directory using CreateFile, specify the FILE_FLAG_BACKUP_SEMANTICS flag as part of dwFlagsAndAttributes. Appropriate security checks still apply when this flag is used without SE_BACKUP_NAME and SE_RESTORE_NAME privileges.

    It looks like you've previously tried some of this but commented it out? If this doesn't work for you, you might want to make sure that they the user you're running as has permission to acess the directory in question.

提交回复
热议问题