// using System.Text; // using System.Runtime.InteropServices; [DllImport("shlwapi")] private static extern int StrFormatByteSize64(long qdw, StringBuilder pszBuf, uint cchBuf); private static string StrFormatByteSize64(long qdw) { StringBuilder StrSize = new StringBuilder(64); StrFormatByteSize64(qdw, StrSize, 64U); return StrSize.ToString(); } // Exemples StrFormatByteSize64(532L); // "532 bytes" StrFormatByteSize64(1340L); // "1,30 KB" StrFormatByteSize64(23506L); // "22,9 KB" StrFormatByteSize64(2400016L); // "2,28 MB" StrFormatByteSize64(2400000000L); // "2,23 GB" StrFormatByteSize64(5466554984654L); // "4,97 TB" StrFormatByteSize64(11874650654198465L); // "10,5 PB" StrFormatByteSize64(7266167416426541069L); // "6,30 EB" StrFormatByteSize64(long.MaxValue); // "7,99 EB"