1 changed file
BExplorer/BetterExplorer/HelperClasses | ||
FriendlySizeConverter.cs | ||
FriendlySizeConverter.cs
/BExplorer/BetterExplorer/HelperClasses/FriendlySizeConverter.cs-3+15/BExplorer/BetterExplorer/HelperClasses/FriendlySizeConverter.cs
Add comment 1 using System;
Add comment 2 Minus using System.Collections.Generic;
Add comment 3 Minus using System.Linq;
Add comment 4 Minus using System.Text;
Add comment 5 2
Add comment 6 3 namespace BetterExplorer {
Add comment 4 Plus
Add comment 5 Plus /// <summary>Contains functionality for presenting the size of a file</summary>
Add comment 7 6 public class FriendlySizeConverter {
Add comment 7 Plus
Add comment 8 Plus /// <summary>The various units in which to display the size of a file</summary>
Add comment 8 9 public enum FileSizeMeasurements {
Add comment 9 10 Bytes = 0,
Add comment 10 11 Kilobytes = 1,
Add comment 12 13 Gigabytes = 3,
Add comment 13 14 }
Add comment 14 15
Add comment 16 Plus /// <summary>
Add comment 17 Plus /// Converts a the size of a file in units (<see cref="FileSizeMeasurements"/> and <see cref="double"/>) into the number of bytes
Add comment 18 Plus /// </summary>
Add comment 19 Plus /// <param name="size"></param>
Add comment 20 Plus /// <param name="type"></param>
Add comment 21 Plus /// <returns></returns>
Add comment 15 22 public static long GetByteLength(double size, FileSizeMeasurements type) {
Add comment 16 23 switch (type) {
Add comment 17 24 case FileSizeMeasurements.Bytes:
Add comment 27 34 }
Add comment 28 35 }
Add comment 29 36
Add comment 37 Plus /// <summary>
Add comment 38 Plus /// Converts bytes into a user friendly string converted into larger units when desired.
Add comment 39 Plus /// </summary>
Add comment 40 Plus /// <param name="bytes">The number of bytes</param>
Add comment 41 Plus /// <returns></returns>
Add comment 30 42 public static string GetFriendlySize(double bytes) {
Add comment 31 43 if (bytes < 1000)
Add comment 32 44 return bytes.ToString() + " B";