|
in addition to showing it in MB, is there anyway to show the folder size with comas? I have huge folder sizes with digital video files in em. Some folders are 30GB in size. it is hard to see em easily.
They look like this;
__745588 KB
21370766 KB
15270845 KB
33450980 KB
if displayed in MB they'd look like this;
___745 MB
_21370 MB
_15270 MB
_33450 MB
It's still confuseing. Is it possibly to put commas in so they look like this?;
___745 MB
21,370 MB
15,270 MB
33,450 MB
|
|
|
|
|
how about using String.Format("{0:#,###}", foldersize)
|
|
|
|
|
how about using String.Format("{0:#,###}", foldersize)
|
|
|
|
|
this is brilliant! cheers :P
scott
|
|
|
|
|
Hi, i'm boogie from Korea.
It is the exact source that i've been looking for!
What a cool stuff that you've made~
ie plug-in for folder size calcuation, what a.. kkk
While i was reading ColHandler.cpp, i found something that would make your source
code more perfect~ (if you correct it)
In GetFolderSize() in ColHandler.cpp, there is recursive function call as follows.
if (!strcmp(fileinfo.cFileName,".") || !strcmp(fileinfo.cFileName,".."))
{
//Do nothing for "." and ".." folders
}
else
{
TCHAR sztmp[512];
strcpy(sztmp,szFilePath);
strcat(sztmp,fileinfo.cFileName);
dwSize = dwSize + GetFolderSize(sztmp); // THIS LINE : FUNCTION_RECURSION
if(dwFolders != NULL)
{
++(*dwFolders);
}
}
I think it's more perfect if you correct that line like this:
dwSize = dwSize + GetFolderSize(sztmp, dwFiles, dwFolders);
This modification doesn't need to be done unless you use dwFiles or dwFolders variables. But if you do, you cannot get the right result if you don't change that line.
Anyway, thanks for registering your source code into this site.
That's been great helpful to me
Regards,
|
|
|
|
|
I need that it show the file size in MB, actually have showing in this format:
138786567 KB
without points, it appears to be very hard to understand.
I want that it show like this: 138 MB
Thanks a lot.
W R
Computadores Colombia
Bogotá D.C.
|
|
|
|
|
I have the same question.
If you know how to set it, please tell me.
Thanks a lot.
|
|
|
|
|
|
Has <bold> anybody got the solution?
|
|
|
|
|
Here is code which convert size into String, with respective postfixes like MB, GB, KB, B etc and also display round off fractions upto two digits.
//----------------------------------------------------------------------------
char * GetSizeString(unsigned long size,char str[])
{
char temp[100]="";
double dsize=size;
if (size==0)
{
ultoa(size,temp,10);
strcat(temp," KB");
}
else if (size<1024)
{
ultoa(size,temp,10);
strcat(temp," B");
}
else if (size<1048576)
{
ULONG rem=size/1024;
ULONG deciml=size- (rem*1024);
ultoa(rem,temp,10);
if (deciml!=0)
{
char temp1[10];
strcat(temp,".");
ultoa(deciml,temp1,10);
temp1[2]=NULL;
strcat(temp,temp1);
}
strcat(temp," KB");
}
else if (size < 1073741824)
{
//dsize /= 1048576.0;
ULONG rem=size/1048576;
ULONG deciml=size- (rem*1048576);
ultoa(rem,temp,10);
if (deciml!=0)
{
char temp1[10];
strcat(temp,".");
ultoa(deciml,temp1,10);
temp1[2]=NULL;
strcat(temp,temp1);
}
//doubleToString(dsize,temp,2);
//gcvt(dsize,5,temp);
strcat(temp," MB");
}
else
{
//dsize /= 1073741824.0;
ULONG rem=size/1073741824;
ULONG deciml=size- (rem*1073741824);
ultoa(rem,temp,10);
if (deciml!=0)
{
char temp1[10];
strcat(temp,".");
ultoa(deciml,temp1,10);
temp1[2]=NULL;
strcat(temp,temp1);
}
//gcvt(dsize,2,temp);
strcat(temp," GB");
}
strcpy(str,temp);
return str;
}
//--------------------------------------------------------------------------
Ayaz
|
|
|
|
|
StrFormatByteSize() does it for you.
CHeers,
Axel
|
|
|
|
|
The screenshot showd the size in mb. The alignment should also have been changed to "right".
|
|
|
|
|
Search for LVCFMT_LEFT in the project and change it to RIGHT to get right alignment. Also search for the line size = dwSize/(1024*1024); in ColHandler.cpp and uncomment the section to convert to MB.
|
|
|
|
|
I'm not a coder, just a user happy to find this. Any chance someone could post a version for MB, right aligned? Would be greatly appreciated!
|
|
|
|
|
I would also like the right aligned MB version if possible. My email is breakaway1029 [at] yahoo [dot] com . Thanks
|
|
|
|
|
me too please~! lonesan (at) gmail (dot) com
thanks
Lone
|
|
|
|
|
i can find these commands but once i have updated the file does this change the dll or should it reregistered ?
i implemented this file by registering the demo dirsize.dll
robbie - happy but confused
|
|
|
|
|
HI
Woluld U be so kind and sent the MB updated version of the DirSize.Dll to jurarafal @ gmail.com , pls
thanks in advance
JUra
jura
|
|
|
|
|
OK, I made the ColHandler.cpp changes suggested and downloaded the Windows Server R2 Platform for SDK and installed it.
For a non-programmer what are the commands necessary to make a new .dll so I can see the files in MB?
MXX wrote: ForumFolder Size Information in the Windows Explorer Details view
Subject:Re: Show size in MB
Sender:MXX
Date :47 27 Dec '04
Search for LVCFMT_LEFT in the project and change it to RIGHT to get right alignment. Also search for the line size = dwSize/(1024*1024); in ColHandler.cpp and uncomment the section to convert to MB.
-Nothing is foolproof for fools can be incredibly ingenious.
|
|
|
|
|
First:
Thanks for that gread add-on. It really makes the explorer more useable.
I suggest changing the text alignment to right-aligned - this improves legibility.
|
|
|
|
|
Very cool add-on, something MS should've added to Explorer a long time ago...
I'll admit I haven't looked at the source yet, nor do I know anything about what's involved in creating such an extension, but...
Since Explorer already has a "Size" column, is it possible at all to use it to display the folder size, instead of having a separate column for this? Right now we end up with this:
<br />
Name Size FolderSize [Type] [OtherColumns]<br />
[foldername] [empty] [size] File Folder<br />
[foldername] [empty] [size] File Folder<br />
[foldername] [empty] [size] File Folder<br />
[filename] [size] [empty] File Type<br />
[filename] [size] [empty] File Type<br />
[filename] [size] [empty] File Type<br />
(damn the formatting...i dunno how to do this) :-p View it using a fixed-size font
|
|
|
|
|
I save a column by reporting files size and folders size in the same one when i got this codes. but for the sake of speed, some rules should be made.
One is 'the limits of Max recusive number of files and/or folders'. If a folder has too many files or subfolders, the answer can just be "too many..." or other flag like ">Max". this limit can be calculated according to CPU's type.
anyway, it's a good stuff, i give my thanks to the coder!
|
|
|
|
|
i make many changes:
-1)add a GetFileSize() function;
-2)give a number gap of 1000, like 3,234,122;
-3)use 2 kinds of unit to make difference, K" for folders, KB for files;
-4)use "files + folders <200" as recusive limit, and add '~' just for large scale folders, it gets much faster;
-5)text fmt is now set to "right" side;
....so "size" column now looks like:
```````````````````~21,813 K"| folder
`````````````````````1,332 KB| file
I put the whole file of "colhandler.cpp", header file is easy to edit.
==========================================================
<small>
#include "stdafx.h"<br />
#include "DirSize.h"<br />
#include "ColHandler.h"<br />
<br />
<br />
STDMETHODIMP CColHandler::Initialize(LPCSHCOLUMNINIT psci)<br />
{<br />
return S_OK;<br />
}<br />
<br />
STDMETHODIMP CColHandler::GetColumnInfo(DWORD dwIndex, SHCOLUMNINFO *psci)<br />
{<br />
TCHAR szText[] = "size";<br />
<br />
psci->scid.fmtid.Data1 = 0x28636AA6L;<br />
psci->scid.fmtid.Data2 = 0x953D;<br />
psci->scid.fmtid.Data3 = 0x11D2;<br />
strcpy((char *)psci->scid.fmtid.Data4,"B5D600C04FD918D0");<br />
<br />
psci->scid.pid = 12;<br />
psci->vt = VT_BSTR;<br />
psci->fmt = LVCFMT_RIGHT; psci->cChars = 35;<br />
psci->csFlags = SHCOLSTATE_TYPE_STR|SHCOLSTATE_SLOW;<br />
<br />
<br />
MultiByteToWideChar( CP_ACP, 0, szText,<br />
strlen(szText)+1, psci->wszTitle, <br />
sizeof(psci->wszTitle)/sizeof(psci->wszTitle[0]) );<br />
<br />
MultiByteToWideChar( CP_ACP, 0, szText,<br />
strlen(szText)+1, psci->wszDescription, <br />
sizeof(psci->wszDescription)/sizeof(psci->wszDescription[0]) );<br />
<br />
if(dwIndex == 0)<br />
{<br />
return S_OK;<br />
}<br />
else<br />
{<br />
return S_FALSE;<br />
}<br />
}<br />
<br />
STDMETHODIMP CColHandler::GetItemData(LPCSHCOLUMNID pscid, LPCSHCOLUMNDATA pscd, VARIANT *pvarData)<br />
{<br />
USES_CONVERSION;<br />
V_VT(pvarData) = VT_BSTR;<br />
DWORD dwSize = 0;<br />
char szTmp[200],sz_[200];<br />
DWORD dwFiles = 0, dwFolders = 0;<br />
BOOL bLimit=false;<br />
<br />
DWORD64 size = 0;<br />
if( pscd->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )<br />
dwSize = GetFolderSize(OLE2T(pscd->wszFile),&dwFiles,&dwFolders,&bLimit);<br />
else<br />
{<br />
dwSize = GetFileSize(OLE2T(pscd->wszFile),&dwFiles,&dwFolders);<br />
}<br />
<br />
{<br />
size = dwSize/1024;<br />
if(dwSize%1024)<br />
size++;<br />
_i64toa(size,szTmp,10);<br />
<br />
int len=strlen(szTmp);<br />
int index=0;<br />
memset(sz_,0,200);<br />
if(bLimit)<br />
{<br />
strcat(sz_,"~"); index+=1;<br />
}<br />
<br />
int iTmp=len%3;<br />
if(iTmp!=0)<br />
{<br />
memcpy(sz_+index,szTmp,iTmp);<br />
index+=iTmp;<br />
len-=iTmp;<br />
<br />
if(len>0)<br />
{<br />
strcat(sz_,",");<br />
++index;<br />
}<br />
}<br />
<br />
while(len>0)<br />
{<br />
memcpy(sz_+index,szTmp+iTmp,3);<br />
index+=3;iTmp+=3;len-=3;<br />
if(len>0)<br />
{<br />
strcat(sz_,",");<br />
++index;<br />
}<br />
}<br />
if( pscd->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )<br />
strcat(sz_," K\"");<br />
else strcat(sz_," KB");<br />
}<br />
<br />
V_BSTR(pvarData) = SysAllocString(T2OLE(sz_));<br />
<br />
return S_OK;<br />
}<br />
<br />
<br />
DWORD CColHandler::GetFolderSize(LPCTSTR szPath, DWORD *dwFiles, DWORD *dwFolders,BOOL *bLimit)<br />
{<br />
TCHAR szFileFilter[512];<br />
TCHAR szFilePath[512];<br />
HANDLE hFind = NULL;<br />
WIN32_FIND_DATA fileinfo;<br />
DWORD dwSize = 0;<br />
<br />
strcpy(szFilePath,szPath);<br />
strcat(szFilePath,"\\");<br />
strcpy(szFileFilter,szFilePath);<br />
strcat(szFileFilter,"*.*");<br />
<br />
<br />
hFind = FindFirstFile(szFileFilter,&fileinfo);<br />
do<br />
{<br />
if(fileinfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )<br />
{<br />
if (!strcmp(fileinfo.cFileName,".") || !strcmp(fileinfo.cFileName,".."))<br />
{<br />
}<br />
else<br />
{<br />
TCHAR sztmp[512];<br />
strcpy(sztmp,szFilePath);<br />
strcat(sztmp,fileinfo.cFileName);<br />
dwSize = dwSize + GetFolderSize(sztmp,dwFiles,dwFolders,bLimit);<br />
if(dwFolders != NULL)<br />
++(*dwFolders);<br />
}<br />
}<br />
else<br />
{<br />
if(dwFiles != NULL)<br />
++(*dwFiles);<br />
}<br />
<br />
dwSize += fileinfo.nFileSizeLow;<br />
if(dwFolders && dwFiles && bLimit)<br />
{<br />
if(*dwFolders+*dwFiles>200)<br />
*bLimit=true;<br />
}<br />
}while(FindNextFile(hFind,&fileinfo)&& ((bLimit!=NULL && !(*bLimit))||!bLimit) );<br />
<br />
FindClose(hFind);<br />
return dwSize;<br />
<br />
}<br />
<br />
DWORD CColHandler::GetFileSize(LPCTSTR szPath, DWORD *dwFiles, DWORD *dwFolders)<br />
{<br />
WIN32_FIND_DATA fileinfo;<br />
HANDLE hFind = FindFirstFile(szPath,&fileinfo);<br />
FindClose(hFind);<br />
return fileinfo.nFileSizeHigh * (MAXDWORD+1) + fileinfo.nFileSizeLow;<br />
}</small>
=====================================================
|
|
|
|
|
Great addition to this.
Did you guys notice that the sorting doesn't work properly now though? it sorts it as if it is a character field, not a numeric field...
Any suggestions on how to fix?
-Matt
|
|
|
|
|
Hello,
i registered the DirSize.dll, but I didn't found any new column named "Folder Size" or something to add to. I have got a german Version of Windows.. may be, thats the "failure"...?
Greetings
Sven
|
|
|
|
|