I want to hide a file in c#. I know the file path and can create a FileInfo object.
How can I hide it?
In computing, a hidden folder (sometimes hidden directory) or hidden file is a folder or file which filesystem utilities do not display by default when showing a directory listing.
A simple trick for Windows is to merely place your sensitive information within a folder and then mark the folder as 'hidden,' which will hide it within the file explorer. To hide a folder, right click on the folder and select the properties option.
The previously accepted answer:
File.SetAttributes(path, FileAttributes.Hidden);
will result in certain other attributes it may have being lost, so you should:
File.SetAttributes(path, File.GetAttributes(path) | 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