카테고리 없음2015. 5. 22. 10:28

CString GetReadableFileSize(double fFileSizeInBytes) 

{

double size = fFileSizeInBytes;

int i = 0;

const TCHAR* units[] = {_T("Bytes"), _T("KB"), _T("MB"), _T("GB"), _T("TB"), _T("PB"), _T("EB"), _T("ZB"), _T("YB")};

while (size > 1024) 

{

size /= 1024;

i++;

}


CString strResult;

strResult.Format(_T("%.*f %s"), i, size, units[i]);

return strResult;

}


[원문 (Original Text) : HUMAN-READABLE FILE SIZE IN C]

Posted by 좋은나무