开发者

Hidden Folder in Application's file system

开发者 https://www.devze.com 2022-12-20 10:28 出处:网络
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 \"Lo

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);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号