PDA

View Full Version : calculating folder size



sferguson
11-18-2003, 10:46 AM
Hello all-

I understand that I can get the size of a file, and *could* recurse a directory, adding all of the file sizes together, hence calculating the total size of the folder. I'm kind of new to AMS, isn't there a simple folder.getSize function? I couldn't find it anywhere in the help or on this board, so if I'm missing something simple please give me a hint.

Brett
11-18-2003, 11:13 AM
That is the only way to do it in AMS50. I wish there were a GetFolderSize() function in the Windows API but there isn't. Even explorer does it the old fashioned way. To speed things up make sure that the StatusDlg is not visible when you run the File.Find function and that you are not using a progress callback.

I suppose a faster function could be made to do the directory search and file size calculation in one pass... it would have to be a different action for that purpose but it probably could be done. Maybe I'll make an action plugin to do that sometime. Or someone could make you a DLL that could do it. Basically it would kjust have to wrap the Windows API functions FindFirstFile, FindNextFile, etc. what adds up the total size of the files as it goes along instead of finding all of the files and then having to do another pass through the results to calcualte the file sizes.