/// <summary> /// 获取KB /// </summary> /// <param name="length">字节</param> /// <returns></returns> public static decimal GetFileLength(decimal length, DW dw) { int size = (int)dw; long _dw = 1; for (int i = 0; i < size; i++) { _dw = _dw * 1024; } decimal fileLlength = length / _dw; return(RoundHelper.Round(fileLlength, 2)); }
/// <summary> /// 获取MB /// </summary> /// <param name="length">字节</param> /// <returns></returns> public static decimal GetFileLength(long length, DW dw) { double res = length * 1.0; int size = (int)dw; long _dw = 1; for (int i = 0; i < size; i++) { _dw = _dw * 1024; } decimal fileLlength = (decimal)res / _dw; return(RoundHelper.Round(fileLlength, 2)); }