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 1-Feb-13 23:18pm
Gbenbam925
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 George Jonsson 359
1 Sergey Alexandrovich Kryukov 355
2 CPallini 335
3 BillWoodruff 324
4 OriginalGriff 237
0 OriginalGriff 5,050
1 CPallini 4,225
2 Sergey Alexandrovich Kryukov 3,639
3 George Jonsson 2,911
4 Gihan Liyanage 2,386


Advertise | Privacy | Mobile
Web04 | 2.8.140916.1 | Last Updated 2 Feb 2013
Copyright © CodeProject, 1999-2014
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