Is there any way that I can programmatically create (and I guess access) hidden folders on a storage device from within c#?
+19
A:
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;
}
Tom Ritter
2008-09-18 13:12:05
First result on google
Tom Ritter
2008-09-18 13:12:31
+9
A:
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 = di.Attributes | FileAttributes.Hidden;
}
Mark Ingram
2008-09-18 13:12:38
+5
A:
CreateHiddenFolder(string name)
{
DirectoryInfo di = new DirectoryInfo(name);
di.Create();
di.Attributes |= FileAttributes.Hidden;
}
Phil J Pearson
2008-09-18 13:21:25