Bietet .NET einen einfachen Weg, um Bytes in KB, MB, GB usw. zu konvertieren?C#

Ein Treffpunkt für C#-Programmierer
Anonymous
 Bietet .NET einen einfachen Weg, um Bytes in KB, MB, GB usw. zu konvertieren?

Post by Anonymous »

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

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);
}
< /code>

etc...

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post