What is the fastest way of getting a file length in .net?
Note: I am accessing files via a network share.
So far I have
- 1.5ms FileInfo.Length
- .5ms FileStream().Length
What is the fastest way of getting a file length in .net?
Note: I am accessing files via a network share.
So far I have
Why not just use FileInfo.Length
?
You could p/invoke the Win32 APIs: CreateFile, GetFileSizeEx, and CloseHandle if you really wanted to.
You could PInvoke the FindFirstFile or GetFileAttributesEx API calls, but that seems like a lot of extra work that the FileInfo class is already doing for you. Otherwise I'm wondering the same thing Scott is: why would you not want to use FileInfo?