- 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
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
- Related Articles
- How to get a file system information using Python?
- C# program to get the extension of a file in C#
- C# program to get the file name in C#
- How to get a snapshot of information about Process API in Java 9?
- How to get information about USB mounted or not in android?
- Program to get JTextArea font information
- C# Program to get the last write time of a file
- C# Program to get the last access time of a file
- How to get information about mobile supports data and voice in android?
- How to get information about mobile supports sms or not in android?
- What information do we get about sunlight from the formation of a rainbow?
- How to get information about network roaming is enabled or not in android?
- How to retrieve specific file(s) information using Get-ChildItem in PowerShell?
- C# Program to rename a file
- C program to delete a file

Advertisements