用 C# 獲取檔案中的位元組數
FileInfo 型別具有一個 Length 屬性,它用於確定一個檔案有多少位元組。
首先,設定檔案 −
FileInfo file = new FileInfo("D:\
ew");現在使用 Length 屬性 −
file.Length
以下是完整程式碼 −
示例
using System;
using System.Linq;
using System.IO;
class Program {
static void Main() {
FileInfo file = new FileInfo("D:\
ew");
long res = file.Length;
Console.WriteLine("Bytes: "+res);
}
}輸出
以下是輸出 −
3259244
廣告
資料結構
網路
關係型資料庫管理系統 (RDBMS)
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP