Click here to Skip to main content
13,502,343 members
Rate this:
Please Sign up or sign in to vote.
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 1-Feb-13 23:18pm
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
Rate this: bad
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.
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Try this

private static void ToggleHidden(bool hide)
   DirectoryInfo d = new DirectoryInfo(@"C:\MySecretFolder");
     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;
     {  // Show the folder.
       // Remove Hidden attribute if set.
       if((atts & FileAttributes.Hidden) == FileAttributes.Hidden)
         atts &= ~FileAttributes.Hidden;

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)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web02 | 2.8.180417.1 | Last Updated 2 Feb 2013
Copyright © CodeProject, 1999-2018
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