PDA

View Full Version : Get Folder Size DLL


Dermot
11-23-2006, 02:03 AM
Here is a small free dll (8.5 kb) that will return the size of a folder. It is very fast even on large folders. You can use Luacom to get the size of a folder but I found that it failed on large folders. Also Luacom will add 288 kb to your app where as this dll only adds 8.5 kb.

Use the link below to go to the xDialog site where you can download an AMS project which contains the dll and shows how to use it.

Download (http://www.xdialog.com/free_stuff.htm)

usernameCasper
11-23-2006, 03:25 AM
nice release. You made that in VB? Looks similar to a dll I made in the past :D :yes

Sincerely,
Casper

Dermot
11-23-2006, 03:32 AM
Thanks.

It's not VB.

Tek
11-23-2006, 09:26 AM
Very nice. But why not use the String.GetFormattedSize action?


-- Get the folder
sFolder = Input.GetText("Input1")

-- If no folder is entered, then exit
if sFolder == "" then
Dialog.Message("No Folder", "Please enter a folder.", MB_OK, MB_ICONEXCLAMATION)
return
end

-- Call the dll to get the size
Size = DLL.CallFunction(_SourceFolder.."\\AutoPlay\\Docs\\xFolderSize.dll", "GetFolderSize", "\""..sFolder.."\"", DLL_RETURN_TYPE_STRING, DLL_CALL_STDCALL)

-- Convert the return value to a number
Size = String.ToNumber(Size)

-- Get the formatted size
FormattedSize = String.GetFormattedSize(Size, FMTSIZE_AUTOMATIC, true);

-- Show the result
Label.SetText("result", "Size: "..FormattedSize)

Dermot
11-23-2006, 10:47 AM
But why not use the String.GetFormattedSize action?
Has that function always been there? I never saw it before.:o

Tek
11-23-2006, 11:11 AM
Hey, it's not like I haven't done that before... at least I know I'm not the only one. :)

Intrigued
11-23-2006, 11:56 AM
That innate AMS function came about shortly after I posted about how to format the sizes. I believe Brett saw that example and created an AMS Action based off of it.

Which is, :yes.

;)

Eagle
11-24-2006, 07:56 AM
Very handy and robust Dermot, thanks for the dll

xDialog looks very usefull too :yes

just a bit of tighter example code for your xFolderSize.dll

-- Get the folder
sFolder = String.TrimRight(Input.GetText("Input1"), nil);
-- If an invalid entry, then exit
if ((sFolder == "") or (not Folder.DoesExist(sFolder))) then
Dialog.Message("No Target Folder Data", "Please enter a valid folder path");
return;
end
-- Call the dll to get the size, converting the return value(type "string") to a number
nSize = String.ToNumber(DLL.CallFunction(_SourceFolder.."\\AutoPlay\\Docs\\xFolderSize.dll", "GetFolderSize", "\""..sFolder.."\"", DLL_RETURN_TYPE_STRING, DLL_CALL_STDCALL));
sSize = String.GetFormattedSize(nSize, FMTSIZE_AUTOMATIC, false);
-- Show the result
Label.SetText("result", "Size: "..sSize);

tks again