FormatSize() public static method

Format a file size nicely. Example: 1048576 becomes "1 MB"
public static FormatSize ( double byteCount ) : string
byteCount double
return string
Ejemplo n.º 1
0
 public override void Write(byte[] buffer, int offset, int count)
 {
     this.stream.Write(buffer, offset, count);
     if (isDebuggingEnabled)
     {
         writepos += count;
         long percentage = (writepos * 100) / (Length > 0?Length:100);
         Logger.Debug(String.Format("{0}% {1} of {2})",
                                    percentage,
                                    Utils.FormatSize(this.writepos),
                                    Utils.FormatSize(Length)));
     }
 }
Ejemplo n.º 2
0
 public override int Read(byte[] buffer, int offset, int count)
 {
     if (isDebuggingEnabled)
     {
         int result = this.stream.Read(buffer, offset, count);
         readpos += result;
         long percentage = (readpos * 100) / (Length > 0?Length:100);
         Logger.Debug(String.Format("{0}% {1} of {2}",
                                    percentage,
                                    Utils.FormatSize(this.readpos),
                                    Utils.FormatSize(Length)));
         return(result);
     }
     else
     {
         return(this.stream.Read(buffer, offset, count));
     }
 }
Ejemplo n.º 3
0
 public LoggingStream(Stream stream, string prefix, string filename, long streamlength)
 {
     this.stream = stream;
     this.length = streamlength;
     this.prefix = String.Format("{0} {1}: ", prefix, filename, Utils.FormatSize(Length));
 }