/// <summary> KB、MB、GB、TB単位へのバイト変換 /// </summary> <param name="len"></param> /// <returns></returns> 公開静的文字列 ConvertBytes(long len) { string[] サイズ = { "Bytes", "KB", "MB", "GB", "TB" }; 整数 = 0; 一方、(len >= 1024 & 次数 + 1 < サイズ。 長さ) //{ 順序++; len = len / 1024; //} return String.Format("{0:0.##} {1}", len, sizes[order]); double leng = Convert。ToDouble(len); string[] サイズ = { "Bytes", "KB", "MB", "GB", "TB" }; 整数 = 0; 一方、(leng >= 1024 && 次数 + 1 < サイズ。 長さ) { 順序++; leng = leng / 1024; } return String.Format("{0:0.##} {1}", leng, sizes[order]); } |