Posts tagged NTFS
How to create NTFS File links Programmatically.
01494 days
by Jijo Raj
in FileSystem
![]()
Unix guys don’t need an introduction about file links, because its one of the beginner Unix skills – how to create a file link. But usually in windows arena, file links may be the least discussed one among beginners. In simple words, file links are – one Physical file in disk but with different file names. All the file names points to the same file. There are a number of usages for file links.
- Hide the master file from a bunch of naughty users.
- You can assign different access rights for different users by creating file links for the same file.( each link have different permissions.)
- To keep the filename constant and you can change the mapping to another file.
- Etc etc… it goes on.
![]()
So how can i create a link for a file? You can use the api – CreateHardLink(). See the sample code snippet below.
CreateHardLink( _T(“c:\\masterfile.dat”), // Source File
_T(“c:\\LinkToMaster.dat”), // Link name
NULL ); // Security attributes
![]()
You can use DeleteFile() to delete the created link.
![]()
Targeted Audience – Beginners.
