CSharp examples for File IO:File
Gets the size of the file.
using System.Web; using System.Text.RegularExpressions; using System.Globalization; using System.Extensions; using System.Web.Mvc; using System.Threading.Tasks; using System.Text; using System.Linq; using System.Collections.Generic; using System.Collections; using System;//from w ww . j a v a 2 s .c om public class Main{ /// <summary> /// Gets the size of the file. /// </summary> /// <param name="Bytes">The bytes.</param> /// <returns></returns> public static string GetFileSize(this long Bytes) { if (Bytes >= 1073741824) { Decimal size = Decimal.Divide(Bytes, 1073741824); return String.Format("{0:##.##} GB", size); } else if (Bytes >= 1048576) { Decimal size = Decimal.Divide(Bytes, 1048576); return String.Format("{0:##.##} MB", size); } else if (Bytes >= 1024) { Decimal size = Decimal.Divide(Bytes, 1024); return String.Format("{0:##.##} KB", size); } else if (Bytes > 0 & Bytes < 1024) { Decimal size = Bytes; return String.Format("{0:##.##} Bytes", size); } else { return "0 Bytes"; } } }