Is there any way that I can programmatically create (and I guess access) hidden folders on a storage device from within c#?
Choosing to hide just the folder will hide that folder from being seen in File Explorer, but won't hide the actual files contained within. The other option is used to hide both the folder and all the data inside, including any subfolders and subfolder files.
It would have to be surgically removed from a boot disk. So no worries there. Make sure System files are hidden only in File Explorer > View > Options > Change Folder and Search Options > View > check Hide Protected Operating System Files, approve security box, Apply, Save.
using System.IO; string path = @"c:\folders\newfolder"; // or whatever if (!Directory.Exists(path)) { DirectoryInfo di = Directory.CreateDirectory(path); di.Attributes = FileAttributes.Directory | FileAttributes.Hidden; }
Yes you can. Create the directory as normal then just set the attributes on it. E.g.
DirectoryInfo di = new DirectoryInfo(@"C:\SomeDirectory"); //See if directory has hidden flag, if not, make hidden if ((di.Attributes & FileAttributes.Hidden) != FileAttributes.Hidden) { //Add Hidden flag di.Attributes |= FileAttributes.Hidden; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With