ASP.Net Get File Size
If you want to get the size of a file in ASP.NET (C#), do this:
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() + " KB)");


Thanks..
useful.. :)
Thank you very much
its very usefuly for me
Thanks for ur solution
Regards
Ranjith
Thanks dude. I got a straight forward answer.
Thanks dude, just what i was looking for. i needed it in vb so i converted it.
Hope the code helps some others
Dim finfo As FileInfo = New FileInfo(fileName)
Dim FileInBytes As Integer = finfo.Length
Thanks a lot Sir, this was utmost helpful…
Thanks a lot, this is solve my problem
Straight and direct answer to what i need. Thanx Man..
Thanks a lot.
Help me a lot.
Thanks a lot, very much useful
Just what I needed. Thanks.
It helps me a lot. Thanks
I’m getting the following error:
System.Web.HttpException: ‘http://www.example.com’ is not a valid virtual path.
I didn’t really use example.com, but it doesn’t recognize any website I plug in there. I even tried linking to an image, and the image wasn’t “a valid virtual path” either. What could the problem be?
Works perfectly. Thanks :)
Thanks,
Really helped me…
thanks man
Thanka a lot..
Thanks for your code.
It is very useful to me.
grt…
thnks