Hello everyone. I want to create a function that calculate size of specified folder. It is possible? If yes help me please.
Thx )
Professional Software Development Tools
Hello everyone. I want to create a function that calculate size of specified folder. It is possible? If yes help me please.
Thx )
Sure it's possible -- you'll want to use File.Find() and scan recursively. Then for each file; get it's size using File.GetSize() and sum them up.
This will give you the folder's files space in use; not the actual space the files take up. (there's a subtle difference)
below is pure air code (ie: untested) but should get you going...
Code:function Folder.GetSize( cFolder ) --[[ Function returns -1 if folder does not exist, otherwise it returns the sum of all files w/in it. --]] local nSize=-1; if Folder.DoesExist( cFolder ) then local tFiles = File.Find(cFolder,"*.*",true,false); nSize = 0; if tFiles and type(tFiles) == "table" then local x; for x=1,Table.Count(tFiles) do nSize = nSize + File.GetSize( tFiles[x] ); end end end return nSize; end
Last edited by jassing; 07-01-2009 at 02:39 PM.
(Click here to contact me)
Providing Independent Professional Consulting Services for
IndigoRose products, World Wide.
Located in -8:00 (-7:00 DST) GMT Timezone (Western United States)
Perfectly work! Thank you for help dude!![]()
thanks great coding