Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide a file or directory using the Windows API from C

I want to modify a C program to make some of the files it creates hidden in Windows. What Windows or (even better) POSIX API will set the hidden file attribute?

like image 816
Johannes Brodwall Avatar asked Jul 27 '09 18:07

Johannes Brodwall


1 Answers

You can do it by calling SetFileAttributes and setting the FILE_ATTRIBUTE_HIDDEN flag. See http://msdn.microsoft.com/en-us/library/aa365535%28VS.85%29.aspx

This is not POSIX though. To create a 'hidden' file under a normal POSIX system like Linux, just start a filename with a dot (.).

like image 116
Rutger Nijlunsing Avatar answered Oct 13 '22 20:10

Rutger Nijlunsing