Click here to Skip to main content
15,894,017 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Please I need a function with which I can make sensitive folders hidden.
There is this application I developped and there are certain folders I want
hidden from users because they contain certain sensitive
data that I do not wish to be in the registry. I know that CreateFile
Function has facility for hidding files but I don't think CreateDirectory
function has the same. Is there such a function?
Posted
Comments
Jibesh 2-Feb-13 5:26am    
do you know even if you hide the folder someone still can view hidden files/folder, can search hidden files/folder by turn on folder settings

If you want to secure sensitive information, then hiding a folder is not going to do more than put a band-aid on an amputation.
It is trivially easy to open hidden folders - either with Windows Explorer (look under "Organise...Folder and search options...View Tab...Show hidden files, folders and drives") or with a simple application - which completely ignores the hidden flag (or your program couldn't find it either).

Instead, store your data in a conventional place (see here: Where should I store my data?[^]) and use encryption to secure it from view.
 
Share this answer
 
Try this

C#
private static void ToggleHidden(bool hide)
 {
   DirectoryInfo d = new DirectoryInfo(@"C:\MySecretFolder");
   if(d.Exists)
   {
     FileAttributes atts = d.Attributes;
     if(hide == true)
     { // Hide the folder.
       // Append Hidden attribute only if not already set.
       if((atts & FileAttributes.Hidden) != FileAttributes.Hidden)
         atts |= FileAttributes.Hidden;
     }
     else
     {  // Show the folder.
       // Remove Hidden attribute if set.
       if((atts & FileAttributes.Hidden) == FileAttributes.Hidden)
         atts &= ~FileAttributes.Hidden;
     }
}

hiding-directories-programatically-in-c-sharp[^]
 
Share this answer
 
Comments
Gbenbam 2-Feb-13 5:38am    
I want one for C++

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900