Does folders in windows have IDs? or GUIDs?

2019-07-18 07:44发布

问题:

what I'm trying to do, I'm selecting a folder and copying it, I would like to avoid copying it again if the folder got renamed. so is there an ID for each folder in windows that stick with the folder till its deleted ?

C# would be perfect, or C++

回答1:

I think you looking somewhat like this :Unique file ids for Windows - Unique ID for files on NTFS?

Windows can give a unique file indentifier using the function GetFileInformationByHandle()

Example: (hFile is a handle to a file)

BY_HANDLE_FILE_INFORMATION FileInfo;

GetFileInformationByHandle(hFile, &FileInfo);
inode= FileInfo.nFileIndexLow | (FileInfo.nFileIndexHigh << 32);
volume=FileInfo.dwVolumeSerialNumber;

I got similar SO thread here, that will help you implement that you are looking for..

Unique File Identifier ane Unique Folder Identifier



回答2:

I dont think there is a way to find out for folders.