Get File Size

Nov 5 2007 5:37 AM
Hi, In short: I have a local file and I need to get the filesize. I thought this would have been an easy job, but a search ends up with zero results and a quick google doesn't give me any satisfying results eather. Logically speaking I would have thought the File class would have been the way to go, but there's no GetSize() or Size exposed. I guess I can get the length by doing this: int localSize = File.ReadAllBytes(@".\Temp\DSAnalyserReport.tmp").Length; But reading the whole file just to get the size looks like an expensive way to get there. Any suggestions?

Answers (2)