Calculate Size of a particular file



In my scenario I want to upload a document using Browse button and providing path of the file.

But upload portal has a limitation that we can not upload a document whose size is greater than 2MB. Is there any way by which we can calculate the file size before uploading? The document is mostly in PDF or JPEG format.

Thanks in advance… :slight_smile:


Hey @mgangrade7

FileInfo.Length will return the length of file, in bytes (not size on disk), so this is what you are looking for, I think.

If you have already a file path as input, this is the code you need:

long length = new System.IO.FileInfo(path).Length;


Get file size

What abt directory size?


Yes you can calculate that as well. Singel level like below :slight_smile:
Get The Directory Size_at_single_level.xaml (6.6 KB)



How can we retrieve drive details


Hey @ndivya

Check the existing thread and let me know: