2

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++

Arrabi
  • 3,718
  • 4
  • 26
  • 38
  • 1
    Here's some research options: http://stackoverflow.com/questions/3482178/how-do-you-read-the-128-bit-ntfs-file-id-for-a-directory-and-or-file http://stackoverflow.com/questions/1866454/unique-file-identifier-in-windows – Snixtor May 21 '12 at 06:30

2 Answers2

4

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

Community
  • 1
  • 1
Niranjan Singh
  • 18,017
  • 2
  • 42
  • 75
  • Old post. However: this question should be marked as answer. As long as the parameters are right in the CreateFile() function, it is possible to get a unique ids for directories. – Harald Jul 26 '17 at 18:53
  • @Harald: Please check these [Getting a Folder ID C#](https://stackoverflow.com/questions/16389383/getting-a-folder-id-c-sharp?noredirect=1&lq=1) and [unique information in each file or folder NTFS](https://stackoverflow.com/questions/12425331/unique-information-in-each-file-or-folder-ntfs?noredirect=1&lq=1) – Niranjan Singh Jul 27 '17 at 05:51
0

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

  • Old post... However: wrong. This is at least possible for NTFS systems since Windows XP came out. – Harald Jul 26 '17 at 18:55