/// <summary> Bajty na jednostki KB, MB, GB, TB – inteligentna konwersja /// </summary> <nazwa parametru="len"></param> /// <returns></returns> publiczny statyczny ciąg ConvertBytes (długa leczka) { string[] rozmiary = { "bajty", "KB", "MB", "GB", "TB" }; int kolejność = 0; podczas gdy (len >= 1024 & rząd + 1 < rozmiarów. Długość) //{ porządek++; len = len / 1024; //} return String.Format("{0:0.##} {1}", len, sizes[order]); double leng = Convert.ToDouble(len); string[] rozmiary = { "bajty", "KB", "MB", "GB", "TB" }; int kolejność = 0; podczas gdy (leng >= 1024 & porządek + 1 < rozmiarów. Długość) { porządek++; leng = leng / 1024; } return String.Format("{0:0.##} {1}", leng, sizes[order]); } |