FileInfo प्रकार में एक लंबाई संपत्ति होती है जो यह निर्धारित करती है कि फ़ाइल में कितने बाइट हैं।
सबसे पहले, फ़ाइल सेट करें -
FileInfo file = new FileInfo("D:\\new"); अब लेंथ प्रॉपर्टी का इस्तेमाल करें -
file.Length
ये रहा पूरा कोड -
उदाहरण
using System;
using System.Linq;
using System.IO;
class Program {
static void Main() {
FileInfo file = new FileInfo("D:\\new");
long res = file.Length;
Console.WriteLine("Bytes: "+res);
}
} आउटपुट
निम्न आउटपुट है -
3259244