ফাইলের ইনফরমেশন পাওয়া মানে সেটি কি কি অ্যাট্রিবিউট সহ সেট আছে তা জানা। উদাহরণস্বরূপ, একটি ফাইল নরমাল, হিডেন, আর্কাইভড, ইত্যাদি হতে পারে।
প্রথমে FileInfo ক্লাস ব্যবহার করুন −
FileInfo info = new FileInfo("hello.txt");
এখন, FileAttributes ব্যবহার করে ফাইলের ইনফরমেশন পান −
FileAttributes attr = info.Attributes;
কোডটি নিচে দেওয়া হলো −
উদাহরণ
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);
}
}
আউটপুট
Normal