Get file size using ASP.net

Collapse

Unconfigured Ad Widget

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • Manuel_
    Banned
    • May 2005
    • 120

    Get file size using ASP.net

    If you want to get the size of a file in ASP.NET (C#), check the below code:
    string MyFile = "~/photos/mymug.gif";

    FileInfo finfo = new FileInfo(Server.MapPath(MyFile));
    long FileInBytes = finfo.Length;
    long FileInKB = finfo.Length / 1024;

    Response.Write("File Size: " + FileInBytes.ToString() +
    " bytes (" + FileInKB.ToString() + " K");
    Last edited by admin; 08-13-2015, 11:52 AM.
Working...
X