Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
Check if a File is hidden in C#
To retrieve the attributes of a file, use the FileAttributes Eumeration. It has various members like compressed, directory, hidden, etc.
To check if a file is hidden, use the hidden member name.
If the FileAttributes.hidden is set that would mean the file is hidden. Firstly, get the path to find the attributes.
FileAttributes attributes = File.GetAttributes(path);
If the following is set, that would mean the file is now hidden using the hidden member name.
File.SetAttributes(path, File.GetAttributes(path) | FileAttributes.Hidden);
Console.WriteLine("The {0} file is hidden.", path);
Advertisements
