Bietet .NET eine einfache Möglichkeit, Bytes in KB, MB, GB usw. zu konvertieren?

Ich frage mich nur, ob .NET eine saubere Möglichkeit bietet, dies zu tun:

int64 x = 1000000;
string y = null;
if (x / 1024 == 0) {
    y = x + " bytes";
}
else if (x / (1024 * 1024) == 0) {
    y = string.Format("{0:n1} KB", x / 1024f);
}

usw...

Antworten auf die Frage(3)

Ihre Antwort auf die Frage