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
How to open hidden file using C#?
To open a hidden file, first make it visible. You can do this by removing the hidden attribute set on it −
FileInfo file= new FileInfo(Environment.CurrentDirectory + @"\myFile.txt"); file.Attributes &= ~FileAttributes.Hidden;
Now treat it as a normal text file and open it. Read the content −
using (StreamReader sr = new StreamReader("myFile.txt")) {
string line;
while ((line = sr.ReadLine()) != null) {
Console.WriteLine(line);
}
}
After reading, set the attribute as hidden again to hide the file −
file.Attributes |= FileAttributes.Hidden;
Advertisements
