Hidden Folder in Application's file system
I have an application that on closing, it writes to a开发者_开发百科 log file. BUT I don't really want users to notice it (the file is already readonly). So I just want to hide the folder called "Logs". How can I make the folder hidden?
You can do this by setting the FileAttributes for the file or directory to include FileAttributes.Hidden.
This can be done via the DirectoryInfo.Attributes property for the folder in question.
You can set the DirectoryInfo
attributes to indicate that it should be hidden.
DirectoryInfo di = Directory.CreateDirectory("C:\Logs"); //or whatever
di.Attributes = di.Attributes | FileAttributes.Hidden;
I've assumed a Microsoft environment, given the C# tag. Try:
File.SetAttributes(filePath, File.GetAttributes(filePath) | FileAttributes.Hidden);
精彩评论