- Home /
How do I get the filesize of a file on the user's hard drive?
How do I quickly determine the file size of a file on the user's hard drive? This is for a standalone build, not a web player build.
I have tried System.IO.File.Length (which I know won't work) and System.IO.FileInfo.Length but each one throws up an error. I am using System.IO.File for other things and it works fine, like System.IO.File.Exists, etc. but I can't seem to be able to get filesize info.
Is there some easy way to get this information?
Comment
Best Answer
Answer by whydoidoit · Jun 21, 2013 at 07:33 AM
You need to use System.IO.FileInfo.
var fileInfo = new System.IO.FileInfo("some/Path");
Debug.Log(fileInfo.Length);
Perfect, thank you. I had done exactly this already, but in my late night coding frenzy I forgot the "var" before the declaration. That'll $$anonymous$$ch me.