webdav portal fixes
This commit is contained in:
parent
a4cb95e2db
commit
0a64381dac
10 changed files with 161 additions and 5 deletions
|
@ -0,0 +1,31 @@
|
|||
using System;
|
||||
|
||||
namespace WebsitePanel.WebDavPortal.Helpers
|
||||
{
|
||||
public class ViewDataHelper
|
||||
{
|
||||
public static string BytesToSize(long bytes)
|
||||
{
|
||||
if (bytes == 0)
|
||||
{
|
||||
return string.Format("0 {0}", Resources.UI.Byte);
|
||||
}
|
||||
|
||||
var k = 1024;
|
||||
|
||||
var sizes = new[]
|
||||
{
|
||||
Resources.UI.Bytes,
|
||||
Resources.UI.KilobyteShort,
|
||||
Resources.UI.MegabyteShort,
|
||||
Resources.UI.GigabyteShort,
|
||||
Resources.UI.TerabyteShort,
|
||||
Resources.UI.PetabyteShort,
|
||||
Resources.UI.ExabyteShort
|
||||
};
|
||||
|
||||
var i = (int) Math.Floor(Math.Log(bytes)/Math.Log(k));
|
||||
return string.Format("{0} {1}", Math.Round(bytes/Math.Pow(k, i), 3), sizes[i]);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue