- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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;
- Related Articles
- How to open and close a PDF file using Swift?
- How to open a plain text file in C#?
- How to open multiple files using a File Chooser in JavaFX?
- Check if a File is hidden in C#
- How to get the system configuration information relevant to an open file using Python?
- How to open a file to write in Python?
- How to implement Open Closed principle using C#?
- How to open a plain text file in Java?
- How to open a file just to read in python?
- How to open a file in binary mode with Python?
- How to open a file in append mode with Python?
- How to get the current open file line in Python?
- How to find the file using C#?
- How to get hidden files and folders using PowerShell?
- How to ignore hidden files using os.listdir() in Python?

Advertisements