Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ Windows
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 2-Feb-13 0:18am
Gbenbam1.1K
Comments
jibesh at 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
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Try this
 
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[^]
  Permalink  
Comments
Gbenbam at 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)

  Print Answers RSS
0 Mika Wendelius 241
1 Abhinav S 155
2 Peter Leow 140
3 Sergey Alexandrovich Kryukov 135
4 Kornfeld Eliyahu Peter 115
0 Sergey Alexandrovich Kryukov 8,613
1 OriginalGriff 6,536
2 Peter Leow 3,727
3 Zoltán Zörgő 3,456
4 Richard MacCutchan 2,442


Advertise | Privacy | Mobile
Web04 | 2.8.150123.1 | Last Updated 2 Feb 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100