有什么方法可以从c#中以编程方式创建(并且我猜访问)存储设备上的隐藏文件夹?
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; }
是的你可以.正常创建目录然后只需在其上设置属性.例如
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; }
CreateHiddenFolder(string name) { DirectoryInfo di = new DirectoryInfo(name); di.Create(); di.Attributes |= FileAttributes.Hidden; }