![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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
C# Program to get information about a file
To get information about a file means to get what all attributes are set for that particular file. For example, a file can be normal, hidden, archived, etc.
Firstly, use the FileInfo class −
FileInfo info = new FileInfo("hello.txt");
Now, use FileAttributes to get information about a file −
FileAttributes attr = info.Attributes;
The following is the code −
Example
using System.IO; using System; public class Program { public static void Main() { using (StreamWriter sw = new StreamWriter("hello.txt")) { sw.WriteLine("This is demo text!"); } FileInfo info = new FileInfo("hello.txt"); FileAttributes attr = info.Attributes; Console.WriteLine(attr); } }
Output
Normal
Advertisements