06-08-2009, 11:44 PM
Hello Gintaras:
I am using the following code to calculate the size of a folder and its subfolders, but I have noticed the return value is different from mine
i am running this macro:
Macro
the output is this:
3501233014
16384405434
I am not sure if my own function is processing "all" the files inside the windows directory, or maybe there are problems with owners and privileges, my function is the following:
So the question is: is there another way to execute this thread, maybe as an administrator level or why this code does not process all files?. (I think there is a problem with special characters)
Function get_folder_size
I have another sample
Macro
Output:
0
221617
Thank you!!
Regards.
I am using the following code to calculate the size of a folder and its subfolders, but I have noticed the return value is different from mine
i am running this macro:
Macro
long size1=get_folder_size("c:\windows")
out size1
long size2=GetFileOrFolderSize("c:\windows")
out size23501233014
16384405434
I am not sure if my own function is processing "all" the files inside the windows directory, or maybe there are problems with owners and privileges, my function is the following:
So the question is: is there another way to execute this thread, maybe as an administrator level or why this code does not process all files?. (I think there is a problem with special characters)
Function get_folder_size
function str'folder
long fsize=0
str dotfolder
dotfolder.right(folder,1)
if(folder.len>0&&StrCompare(dotfolder,".")!=0);;test against .. and .
,str ffilter=folder
,ffilter+"\*.*";;set filter and path
,WIN32_FIND_DATA struFind
,int threadFind=FindFirstFile(ffilter, &struFind)
,rep
,,;; I used this instead of struFind.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY
,,;; because i think it is a way of testing against many different types of directories like hidden,system, etc.
,,if((struFind.dwFileAttributes|FILE_ATTRIBUTE_DIRECTORY)==struFind.dwFileAttributes)
,,,str fname.format("%s",&struFind.cFileName);; ****I think the problem is here**
,,,;; but i don't know how to get special characters***
,,,;;set next child
,,,str childFolder=""
,,,childFolder+folder
,,,childFolder+"\"
,,,childFolder+fname
,,,out childFolder
,,,long f_bytes=get_folder_size(childFolder);;recursive call
,,,fsize=fsize+f_bytes
,,else
,,,fsize=fsize+struFind.nFileSizeLow
,,if(FindNextFile(threadFind &struFind)==0)
,,,long er=GetLastError()
,,,if (er!=18);; 18 is there aren't files or folders
,,,,out er;; i get 6 very often i think it's becaus special characters
,,,break
,FindClose threadFind
ret fsizeI have another sample
Macro
str directory="C:\software_test\lang_es\revisión1.2"
long size1=get_folder_size(directory)
out size1
long size2=GetFileOrFolderSize(directory)
out size2Output:
0
221617
Thank you!!
Regards.
