I want to share with you how to get the file size in
asp.net. Its very simple...
Code:C#
You will need to import the following namespace.
Using System.IO;Code:C#
You will need to import the following namespace.
string sMyFileName = "~/rajadurai/raja.jpg";
FileInfo finfo = new FileInfo(Server.MapPath(sMyFileName ));
long FileInBytes = finfo.Length;
long FileInKB = finfo.Length / 1024;
long FileInMB = FileInKB /1024;
lblImgSize.Text="File Size: " + FileInBytes.ToString() +" bytes (" + FileInMB.ToString() + " MB)";
No comments:
Post a Comment