The problem is that is a browser function, not anything that C# can do - unless the file is being downloaded from your website in which case it's trivial: Get the FileInfo, and look at the Length property:
long length = new System.IO.FileInfo(path).Length;
But in a browser? You can't control what the user is looking at, and you can't check in advance what size it's going to be. It's possible that if you write a browser extension you may be able to do this, but that won't be in C# - and you'd have to write a new extension of each browser (and hope that the client upgraded from the pre-Anniversary Update Edge which didn't support extensions at all)