markus / ConvertService / ServiceController / Markus.Service.Extensions / Helper / MathBytes.cs @ 5c387707
이력 | 보기 | 이력해설 | 다운로드 (663 Bytes)
1 | 5c387707 | semi | using System; |
---|---|---|---|
2 | using System.Collections.Generic; |
||
3 | using System.Linq; |
||
4 | using System.Text; |
||
5 | using System.Threading.Tasks; |
||
6 | |||
7 | namespace Markus.Service.Helper |
||
8 | { |
||
9 | public static class MathBytes |
||
10 | { |
||
11 | public static long Bytes(double value, DataSizeType dataSize) |
||
12 | { |
||
13 | return System.Convert.ToInt64(Math.Round((value * Math.Pow(1024, (int)dataSize)), 0)); |
||
14 | } |
||
15 | |||
16 | public static double BytesToDataUnit(long value, DataSizeType dataSize) |
||
17 | { |
||
18 | return System.Convert.ToDouble((value / Math.Pow(1024, (int)dataSize))); |
||
19 | } |
||
20 | } |
||
21 | |||
22 | public enum DataSizeType |
||
23 | { |
||
24 | BYTE = 0,kB = 1,MB = 2,GB = 3,TB = 4 |
||
25 | } |
||
26 | } |