unique information in each file or folder NTFS

隐身守侯 提交于 2019-12-11 04:46:27

问题


im working on a project where in i need to populate some files from the server and show them in a webrowser to the user. Where user would be allowed to do basic CRUD operation on the file The problem is that i cannot assign the name of the file/folder as unique id which i need in case a user deletes/renames a file i should be able to identify the file later.

My question is that is there anything unique about any file/folder in NTFS that is unique about them and that can be used? and how that information can be accessed using .NET c#.

Came across the BY_HANDLE_FILE_INFORMATION structure but it probably needs me to pinvoke.

UPDATE 1 - tried looking at the feasibility to use nFileIndexHigh and nFileIndexLow but they would need me to do a pinvoke and also this method cannot be used with folders one link when they mention folders Unique Folder Identifier tells me that it isnt possible.


回答1:


Disregarding the fact that it seems that you don't want to P/Invoke a different approach could be to use the Windows Shell API. This API has the concept of a PIDL which identifies a folder (or "similar" item) in the shell namespace. A PIDL does not change even if the user renames the folder. The drawback is that the Shell API exposes what you see in Windows Explorer, e.g. Desktop is at the root of the hierarchy even though it physically is subfolder somewhere on a disk.




回答2:


I think the FILE_INTERNAL_INFORMATION structure, used to query for the file system's 8-byte file reference number for a file, is what you need. The IndexNumber is a number that uniquely identifies a file. You should use P/invoke to query this information.



来源:https://stackoverflow.com/questions/12425331/unique-information-in-each-file-or-folder-ntfs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!