Is there a programatic shortcut to finding the size of an entire folder/subfolder structure without recursing through it in VFP?
Thanks in advance,
Joe
--- StripMime Report -- processed MIME parts --- multipart/alternative text/plain (text body -- kept) text/html ---
There isn't such a thing in the Win API.
You have to it by yourself, even if it is in C.
Gérard.
Le 30/07/2016 à 13:04, Joe Yoder a écrit :
Is there a programatic shortcut to finding the size of an entire folder/subfolder structure without recursing through it in VFP?
Thanks in advance,
Joe
Thanks - I suspected that.
On Sat, Jul 30, 2016 at 9:12 AM, Gérard LOCHON g-lochon@wanadoo.fr wrote:
There isn't such a thing in the Win API.
You have to it by yourself, even if it is in C.
Gérard.
Le 30/07/2016 à 13:04, Joe Yoder a écrit :
Is there a programatic shortcut to finding the size of an entire folder/subfolder structure without recursing through it in VFP?
Thanks in advance,
Joe
[excessive quoting removed by server]
Not sure if this helps using the scripting runtime
fso = createobject("Scripting.FileSystemObject") folder = fso.GetFolder(GetDir()) ? folder.Size
Al
-----Original Message----- From: ProfoxTech [mailto:profoxtech-bounces@leafe.com] On Behalf Of Joe Yoder Sent: 30 July 2016 15:43 To: profoxtech@leafe.com Subject: Re: API to find the size of an entire folder structure?
Thanks - I suspected that.
I was planning to go the recursive ADIR route but am intrigued by the WSH approach. I had read about it in the past but always assumed it was only available on machines that have been configured to run it. A quick check of the environments I work in now shows they all have it.
I ran the sample code and discovered if I select a folder too high on the root I get an "OLE error code 0x800a00046: Unknown COM status code." error. Other than that I think I will find the functions quite useful.
Thanks again - Joe
On Sat, Jul 30, 2016 at 10:19 AM, Jean MAURICE jsm.maurice@wanadoo.fr wrote:
Why not create a recursive function with ADIR() ?
The Foxil
[excessive quoting removed by server]
On Jul 30, 2016, at 8:43 AM, Joe Yoder joe@wheypower.com wrote:
Thanks - I suspected that.
This is one area where I suspect Linux has an advantage. Looks at all the different ways to approach it: http://www.codecoffee.com/tipsforlinux/articles/22.html
-- Ed Leafe
--- StripMime Report -- processed MIME parts --- multipart/signed text/plain (text body -- kept) application/pgp-signature ---
Another useful tool is vfp2c32.fll from VFPx. It has lots of file/folder functions e.g. ADirInfo().
Laurie
On 31 July 2016 at 06:29, Edward Leafe ed@leafe.com wrote:
On Jul 30, 2016, at 8:43 AM, Joe Yoder joe@wheypower.com wrote:
Thanks - I suspected that.
This is one area where I suspect Linux has an advantage. Looks at all the different ways to approach it: http://www.codecoffee.com/tipsforlinux/articles/22.html
-- Ed Leafe
--- StripMime Report -- processed MIME parts --- multipart/signed text/plain (text body -- kept) application/pgp-signature
[excessive quoting removed by server]
Try this 100% VFP solution. It puts the recursive contents of a folder into a cursor with file size and you can then sum the size.
***************** * START OF CODE ***************** * Display Files in a Folder within a Table * Written by: Dave Crozier * Amendments: * 04/09/2015 - Add in field to contain file size for Paul Newton * Clear All
Clear
Public oForm
oForm=Createobject("MyForm",Addbs(Getdir("c:\temp")),"*.*",.F.)
Define Class MyForm As Form AllowOutput=.F. && so '?' output goes to screen Width=_Screen.Width Height=_Screen.Height-50 Width=1024 Height=798
Procedure Init(cPath As String, cMask As String, fSubDir As Boolean) Set Exclusive Off Set Safety Off Set Talk Off Set Exact Off Create Cursor Files (Path c(240),fname c(240),Fsize N(10,0),Timestamp T)
This.DoDir(cPath,cMask)
Index On Timestamp Descending Tag T && choose your desired order
* INDEX on fsize DESCENDING TAG fsize
With This .AddObject("gr","grid") With .gr .AllowCellSelection=.F. .Visible=1 .Height=Thisform.Height .Width = Thisform.Width .AutoFit .Column3.InputMask="999,999,999" Endwith .Show * Endwith Procedure DoDir(cPath As String, cMask As String)
Local N,i,aa[1]
N=Adir(aa,cPath+cMask,"",1)
For i = 1 To N
Insert Into Files (Path,fname,Fsize,Timestamp) Values ; (cPath, aa[i,1], aa[i,2], Ctot(Dtoc(aa[i,3])+aa[i,4]))
Endfor
N=Adir(aa,cPath+"*.*","HD",1) && now without the mask, search for directories
For i = 1 To N
If "D"$aa[i,5] && if it's a dir
If aa[i,1] != '.'
This.DoDir(cPath+aa[i,1]+"",cMask) && recur
Endif
Endif
Endfor
Enddefine * **************** * End of Code ****************
Dave
-----Original Message----- From: ProFox [mailto:profox-bounces@leafe.com] On Behalf Of Laurie Alvey Sent: 31 July 2016 11:22 To: ProFox Email List profox@leafe.com Subject: Re: API to find the size of an entire folder structure?
Another useful tool is vfp2c32.fll from VFPx. It has lots of file/folder functions e.g. ADirInfo().
Laurie
On 31 July 2016 at 06:29, Edward Leafe ed@leafe.com wrote:
On Jul 30, 2016, at 8:43 AM, Joe Yoder joe@wheypower.com wrote:
Thanks - I suspected that.
This is one area where I suspect Linux has an advantage. Looks at all the different ways to approach it: http://www.codecoffee.com/tipsforlinux/articles/22.html
-- Ed Leafe
--- StripMime Report -- processed MIME parts --- multipart/signed text/plain (text body -- kept) application/pgp-signature
[excessive quoting removed by server]
This solution must be corrected, because the path length may exceed the field size limit while recursing thru the directories.
Personnaly, i create another cursor to contains the pathnames : Pathes(pkid i, path m)
When you start a new subdirectory, you insert it in Pathes cursor, and in each row of Files cursor you put the Pathes.pkid instead of the path.
A simple request can join the pertinent data.
So far so good, it runs faster and takes less working storage.
Gérard.
Le 01/08/2016 à 10:53, Dave Crozier a écrit :
Try this 100% VFP solution. It puts the recursive contents of a folder into a cursor with file size and you can then sum the size.
- START OF CODE
- Display Files in a Folder within a Table
- Written by: Dave Crozier
- Amendments:
04/09/2015 - Add in field to contain file size for Paul NewtonClear All
Clear
Public oForm
oForm=Createobject("MyForm",Addbs(Getdir("c:\temp")),"*.*",.F.)
Define Class MyForm As Form AllowOutput=.F. && so '?' output goes to screen Width=_Screen.Width Height=_Screen.Height-50 Width=1024 Height=798
Procedure Init(cPath As String, cMask As String, fSubDir As Boolean) Set Exclusive Off Set Safety Off Set Talk Off Set Exact Off Create Cursor Files (Path c(240),fname c(240),Fsize N(10,0),Timestamp T)
This.DoDir(cPath,cMask) Index On Timestamp Descending Tag T && choose your desired order * INDEX on fsize DESCENDING TAG fsize With This .AddObject("gr","grid") With .gr .AllowCellSelection=.F. .Visible=1 .Height=Thisform.Height .Width = Thisform.Width .AutoFit .Column3.InputMask="999,999,999" Endwith .Show * EndwithProcedure DoDir(cPath As String, cMask As String)
Local N,i,aa[1] N=Adir(aa,cPath+cMask,"",1) For i = 1 To N Insert Into Files (Path,fname,Fsize,Timestamp) Values ; (cPath, aa[i,1], aa[i,2], Ctot(Dtoc(aa[i,3])+aa[i,4])) Endfor N=Adir(aa,cPath+"*.*","HD",1) && now without the mask, search for directories For i = 1 To N If "D"$aa[i,5] && if it's a dir If aa[i,1] != '.' This.DoDir(cPath+aa[i,1]+"\",cMask) && recur Endif Endif EndforEnddefine
- End of Code
Dave
-----Original Message----- From: ProFox [mailto:profox-bounces@leafe.com] On Behalf Of Laurie Alvey Sent: 31 July 2016 11:22 To: ProFox Email List profox@leafe.com Subject: Re: API to find the size of an entire folder structure?
Another useful tool is vfp2c32.fll from VFPx. It has lots of file/folder functions e.g. ADirInfo().
Laurie
On 31 July 2016 at 06:29, Edward Leafe ed@leafe.com wrote:
On Jul 30, 2016, at 8:43 AM, Joe Yoder joe@wheypower.com wrote:
Thanks - I suspected that.
This is one area where I suspect Linux has an advantage. Looks at all the different ways to approach it: http://www.codecoffee.com/tipsforlinux/articles/22.html
-- Ed Leafe
--- StripMime Report -- processed MIME parts --- multipart/signed text/plain (text body -- kept) application/pgp-signature
[excessive quoting removed by server]
I think that creating a cursor and is too much for something that only need to sum file lenghts. Can be done with 2 arrays, one needed for ADIR and one for keeping the paths and subtotals.
2016-08-01 12:48 GMT+02:00 Gérard LOCHON g-lochon@wanadoo.fr:
This solution must be corrected, because the path length may exceed the field size limit while recursing thru the directories.
Personnaly, i create another cursor to contains the pathnames : Pathes(pkid i, path m)
When you start a new subdirectory, you insert it in Pathes cursor, and in each row of Files cursor you put the Pathes.pkid instead of the path.
A simple request can join the pertinent data.
So far so good, it runs faster and takes less working storage.
Gérard.
Le 01/08/2016 à 10:53, Dave Crozier a écrit :
Try this 100% VFP solution. It puts the recursive contents of a folder into a cursor with file size and you can then sum the size.
- START OF CODE
- Display Files in a Folder within a Table
- Written by: Dave Crozier
- Amendments:
04/09/2015 - Add in field to contain file size for PaulNewton
Clear All
Clear
Public oForm
oForm=Createobject("MyForm",Addbs(Getdir("c:\temp")),"*.*",.F.)
Define Class MyForm As Form AllowOutput=.F. && so '?' output goes to screen Width=_Screen.Width Height=_Screen.Height-50 Width=1024 Height=798
Procedure Init(cPath As String, cMask As String, fSubDir AsBoolean) Set Exclusive Off Set Safety Off Set Talk Off Set Exact Off Create Cursor Files (Path c(240),fname c(240),Fsize N(10,0),Timestamp T)
This.DoDir(cPath,cMask) Index On Timestamp Descending Tag T && choose yourdesired order
* INDEX on fsize DESCENDING TAG fsize With This .AddObject("gr","grid") With .gr .AllowCellSelection=.F. .Visible=1 .Height=Thisform.Height .Width = Thisform.Width .AutoFit .Column3.InputMask="999,999,999" Endwith .Show * Endwith Procedure DoDir(cPath As String, cMask As String) Local N,i,aa[1] N=Adir(aa,cPath+cMask,"",1) For i = 1 To N Insert Into Files (Path,fname,Fsize,Timestamp)Values ; (cPath, aa[i,1], aa[i,2], Ctot(Dtoc(aa[i,3])+aa[i,4]))
Endfor N=Adir(aa,cPath+"*.*","HD",1) && now without themask, search for directories
For i = 1 To N If "D"$aa[i,5] && if it's a dir If aa[i,1] != '.'This.DoDir(cPath+aa[i,1]+"",cMask) && recur
Endif Endif EndforEnddefine
- End of Code
Dave
-----Original Message----- From: ProFox [mailto:profox-bounces@leafe.com] On Behalf Of Laurie Alvey Sent: 31 July 2016 11:22 To: ProFox Email List profox@leafe.com Subject: Re: API to find the size of an entire folder structure?
Another useful tool is vfp2c32.fll from VFPx. It has lots of file/folder functions e.g. ADirInfo().
Laurie
On 31 July 2016 at 06:29, Edward Leafe ed@leafe.com wrote:
On Jul 30, 2016, at 8:43 AM, Joe Yoder joe@wheypower.com wrote:
Thanks - I suspected that.
This is one area where I suspect Linux has an advantage. Looks at all the different ways to approach it: http://www.codecoffee.com/tipsforlinux/articles/22.html
-- Ed Leafe
--- StripMime Report -- processed MIME parts --- multipart/signed text/plain (text body -- kept) application/pgp-signature
[excessive quoting removed by server]
Yeah, I know, but I tend to find optimization and speed. It's the same as using "select * into cursor" just for looking the _tally
El 2/8/2016 7:40, "Gérard LOCHON" g-lochon@wanadoo.fr escribió:
Generally, it's multipurpose
Le 02/08/2016 à 00:56, Fernando D. Bozzo a écrit :
I think that creating a cursor and is too much for something that only need to sum file lenghts. Can be done with 2 arrays, one needed for ADIR and one for keeping the paths and subtotals.
[excessive quoting removed by server]
Have used this in C# a long time ago.
long length = Directory.GetFiles(directoryPath,"*",SearchOption.AllDirectories).Sum(t => (new FileInfo(t).Length));
On Tue, Aug 2, 2016 at 12:58 AM, Fernando D. Bozzo fdbozzo@gmail.com wrote:
Yeah, I know, but I tend to find optimization and speed. It's the same as using "select * into cursor" just for looking the _tally
El 2/8/2016 7:40, "Gérard LOCHON" g-lochon@wanadoo.fr escribió:
Generally, it's multipurpose
Le 02/08/2016 à 00:56, Fernando D. Bozzo a écrit :
I think that creating a cursor and is too much for something that only need to sum file lenghts. Can be done with 2 arrays, one needed for ADIR and one for keeping the paths and subtotals.
[excessive quoting removed by server]
You can also use filer.dll like this:
LOCAL oFiler As CFileUtil OF Filer.FileUtil LOCAL i, n, c, o CREATE CURSOR files (fullname V(50), attrib I, bytes I) oFiler = NEWOBJECT("Filer.FileUtil") oFiler.SearchPath = GETDIR() IF EMPTY(oFiler.SearchPath) RETURN ENDIF oFiler.SubFolder = 1 oFiler.FileExpression = "*.*" oFiler.Find(0) n = oFiler.Files.Count IF n > 0 CLEAR FOR i = 1 TO n o = oFiler.Files.Item(i) c = o.Path + o.Name INSERT INTO files VALUES (c, o.Attr, o.Size) ENDFOR ENDIF SUM bytes TO n ? "Total size", CAST(n As B(0))
Laurie
On 2 August 2016 at 12:46, Stephen Russell srussell705@gmail.com wrote:
Have used this in C# a long time ago.
long length = Directory.GetFiles(directoryPath,"*",SearchOption.AllDirectories).Sum(t => (new FileInfo(t).Length));
On Tue, Aug 2, 2016 at 12:58 AM, Fernando D. Bozzo fdbozzo@gmail.com wrote:
Yeah, I know, but I tend to find optimization and speed. It's the same as using "select * into cursor" just for looking the _tally
El 2/8/2016 7:40, "Gérard LOCHON" g-lochon@wanadoo.fr escribió:
Generally, it's multipurpose
Le 02/08/2016 à 00:56, Fernando D. Bozzo a écrit :
I think that creating a cursor and is too much for something that only need to sum file lenghts. Can be done with 2 arrays, one needed for ADIR and one for keeping the paths and subtotals.
[excessive quoting removed by server]
Another solution pure VFP here:
? get_DirSize("c:\Windows\System32\drivers")
PROCEDURE get_DirSize LPARAMETERS tcDir EXTERNAL ARRAY taFiles LOCAL laFiles(1), I, lnFiles
IF VARTYPE(pnDirSize) <> "N" PRIVATE pnDirSize pnDirSize = 0 ENDIF
tcDir = ADDBS(tcDir) lnFiles = ADIR( laFiles, tcDir + '*.*', 'D', 1)
FOR I = 1 TO lnFiles && Look for files IF NOT SUBSTR( laFiles(I,5), 5, 1 ) == 'D' pnDirSize = pnDirSize + laFiles(I,2) ENDIF ENDFOR
FOR I = 1 TO lnFiles && Look for Subdirs IF SUBSTR( laFiles(I,5), 5, 1 ) == 'D' AND NOT INLIST(laFiles(I,1), '.', '..') get_DirSize( tcDir + laFiles(I,1) ) ENDIF ENDFOR
RETURN pnDirSize ENDPROC
2016-08-03 13:43 GMT+02:00 Laurie Alvey trukker41@gmail.com:
You can also use filer.dll like this:
LOCAL oFiler As CFileUtil OF Filer.FileUtil LOCAL i, n, c, o CREATE CURSOR files (fullname V(50), attrib I, bytes I) oFiler = NEWOBJECT("Filer.FileUtil") oFiler.SearchPath = GETDIR() IF EMPTY(oFiler.SearchPath) RETURN ENDIF oFiler.SubFolder = 1 oFiler.FileExpression = "*.*" oFiler.Find(0) n = oFiler.Files.Count IF n > 0 CLEAR FOR i = 1 TO n o = oFiler.Files.Item(i) c = o.Path + o.Name INSERT INTO files VALUES (c, o.Attr, o.Size) ENDFOR ENDIF SUM bytes TO n ? "Total size", CAST(n As B(0))
Laurie
On 2 August 2016 at 12:46, Stephen Russell srussell705@gmail.com wrote:
Have used this in C# a long time ago.
long length = Directory.GetFiles(directoryPath,"*",SearchOption.AllDirectories).Sum(t => (new FileInfo(t).Length));
On Tue, Aug 2, 2016 at 12:58 AM, Fernando D. Bozzo fdbozzo@gmail.com wrote:
Yeah, I know, but I tend to find optimization and speed. It's the same as using "select * into cursor" just for looking the
_tally
El 2/8/2016 7:40, "Gérard LOCHON" g-lochon@wanadoo.fr escribió:
Generally, it's multipurpose
Le 02/08/2016 à 00:56, Fernando D. Bozzo a écrit :
I think that creating a cursor and is too much for something that
only
need to sum file lenghts. Can be done with 2 arrays, one needed for ADIR and one for keeping
the
paths and subtotals.
[excessive quoting removed by server]
Does this walk the folder tree and pull the sizes from en-US, etc, SEP, and on and on... totaling all of the sizes combined?
I am guessing that there is no api that does this in Win7 at least. From the explorer I click for Properties of a BIG folder and it takes a few secs to total up all the content. You see it flashing as it updates.
Case in point C:\Windows 46.1 gig for me. YMMV
On Wed, Aug 3, 2016 at 8:21 AM, Fernando D. Bozzo fdbozzo@gmail.com wrote:
Another solution pure VFP here:
? get_DirSize("c:\Windows\System32\drivers")
PROCEDURE get_DirSize LPARAMETERS tcDir EXTERNAL ARRAY taFiles LOCAL laFiles(1), I, lnFiles
IF VARTYPE(pnDirSize) <> "N" PRIVATE pnDirSize pnDirSize = 0 ENDIF tcDir = ADDBS(tcDir) lnFiles = ADIR( laFiles, tcDir + '*.*', 'D', 1) FOR I = 1 TO lnFiles && Look for files IF NOT SUBSTR( laFiles(I,5), 5, 1 ) == 'D' pnDirSize = pnDirSize + laFiles(I,2) ENDIF ENDFOR FOR I = 1 TO lnFiles && Look for Subdirs IF SUBSTR( laFiles(I,5), 5, 1 ) == 'D' AND NOT INLIST(laFiles(I,1),'.', '..') get_DirSize( tcDir + laFiles(I,1) ) ENDIF ENDFOR
RETURN pnDirSizeENDPROC
2016-08-03 13:43 GMT+02:00 Laurie Alvey trukker41@gmail.com:
You can also use filer.dll like this:
LOCAL oFiler As CFileUtil OF Filer.FileUtil LOCAL i, n, c, o CREATE CURSOR files (fullname V(50), attrib I, bytes I) oFiler = NEWOBJECT("Filer.FileUtil") oFiler.SearchPath = GETDIR() IF EMPTY(oFiler.SearchPath) RETURN ENDIF oFiler.SubFolder = 1 oFiler.FileExpression = "*.*" oFiler.Find(0) n = oFiler.Files.Count IF n > 0 CLEAR FOR i = 1 TO n o = oFiler.Files.Item(i) c = o.Path + o.Name INSERT INTO files VALUES (c, o.Attr, o.Size) ENDFOR ENDIF SUM bytes TO n ? "Total size", CAST(n As B(0))
Laurie
On 2 August 2016 at 12:46, Stephen Russell srussell705@gmail.com
wrote:
Have used this in C# a long time ago.
long length = Directory.GetFiles(directoryPath,"*",SearchOption.AllDirectories).Sum(t => (new FileInfo(t).Length));
On Tue, Aug 2, 2016 at 12:58 AM, Fernando D. Bozzo fdbozzo@gmail.com wrote:
Yeah, I know, but I tend to find optimization and speed. It's the same as using "select * into cursor" just for looking the
_tally
El 2/8/2016 7:40, "Gérard LOCHON" g-lochon@wanadoo.fr escribió:
Generally, it's multipurpose
Le 02/08/2016 à 00:56, Fernando D. Bozzo a écrit :
I think that creating a cursor and is too much for something that
only
need to sum file lenghts. Can be done with 2 arrays, one needed for ADIR and one for keeping
the
paths and subtotals.
[excessive quoting removed by server]
Yes, it totalizes every file that encounters traversing all subdirs. May be an "H" must be added to the "D" for hidden files, I didn't tested with them totally.
The OS haven't a command for this, that's why when you right-click/properties a folder, you can see that in this moment the disk reads a lot, because it's doing the same.
2016-08-03 18:33 GMT+02:00 Stephen Russell srussell705@gmail.com:
Does this walk the folder tree and pull the sizes from en-US, etc, SEP, and on and on... totaling all of the sizes combined?
I am guessing that there is no api that does this in Win7 at least. From the explorer I click for Properties of a BIG folder and it takes a few secs to total up all the content. You see it flashing as it updates.
Case in point C:\Windows 46.1 gig for me. YMMV
On Wed, Aug 3, 2016 at 8:21 AM, Fernando D. Bozzo fdbozzo@gmail.com wrote:
Another solution pure VFP here:
? get_DirSize("c:\Windows\System32\drivers")
PROCEDURE get_DirSize LPARAMETERS tcDir EXTERNAL ARRAY taFiles LOCAL laFiles(1), I, lnFiles
IF VARTYPE(pnDirSize) <> "N" PRIVATE pnDirSize pnDirSize = 0 ENDIF tcDir = ADDBS(tcDir) lnFiles = ADIR( laFiles, tcDir + '*.*', 'D', 1) FOR I = 1 TO lnFiles && Look for files IF NOT SUBSTR( laFiles(I,5), 5, 1 ) == 'D' pnDirSize = pnDirSize + laFiles(I,2) ENDIF ENDFOR FOR I = 1 TO lnFiles && Look for Subdirs IF SUBSTR( laFiles(I,5), 5, 1 ) == 'D' AND NOTINLIST(laFiles(I,1),
'.', '..') get_DirSize( tcDir + laFiles(I,1) ) ENDIF ENDFOR
RETURN pnDirSizeENDPROC
2016-08-03 13:43 GMT+02:00 Laurie Alvey trukker41@gmail.com:
You can also use filer.dll like this:
LOCAL oFiler As CFileUtil OF Filer.FileUtil LOCAL i, n, c, o CREATE CURSOR files (fullname V(50), attrib I, bytes I) oFiler = NEWOBJECT("Filer.FileUtil") oFiler.SearchPath = GETDIR() IF EMPTY(oFiler.SearchPath) RETURN ENDIF oFiler.SubFolder = 1 oFiler.FileExpression = "*.*" oFiler.Find(0) n = oFiler.Files.Count IF n > 0 CLEAR FOR i = 1 TO n o = oFiler.Files.Item(i) c = o.Path + o.Name INSERT INTO files VALUES (c, o.Attr, o.Size) ENDFOR ENDIF SUM bytes TO n ? "Total size", CAST(n As B(0))
Laurie
On 2 August 2016 at 12:46, Stephen Russell srussell705@gmail.com
wrote:
Have used this in C# a long time ago.
long length =
Directory.GetFiles(directoryPath,"*",SearchOption.AllDirectories).Sum(t
=> (new FileInfo(t).Length));
On Tue, Aug 2, 2016 at 12:58 AM, Fernando D. Bozzo <
fdbozzo@gmail.com>
wrote:
Yeah, I know, but I tend to find optimization and speed. It's the same as using "select * into cursor" just for looking the
_tally
El 2/8/2016 7:40, "Gérard LOCHON" g-lochon@wanadoo.fr escribió:
Generally, it's multipurpose
Le 02/08/2016 à 00:56, Fernando D. Bozzo a écrit :
> I think that creating a cursor and is too much for something
that
only
> need > to sum file lenghts. > Can be done with 2 arrays, one needed for ADIR and one for
keeping
the
> paths and subtotals. > >
[excessive quoting removed by server]
Note, also, that the total size of the files will be less than the total size they take on disk. Because of the way FAT and NTFS allocate large blocks of the disk, a bunch of small files will take up a lot more space on the disk than you may imagine.
Of course, there's a VFP function to tell you cluster size, too. Check out SYS(2022), but read the caution in the Hacker's Guide, as the function isn't always accurate.
On Wed, Aug 3, 2016 at 1:18 PM, Fernando D. Bozzo fdbozzo@gmail.com wrote:
Yes, it totalizes every file that encounters traversing all subdirs. May be an "H" must be added to the "D" for hidden files, I didn't tested with them totally.
The OS haven't a command for this, that's why when you right-click/properties a folder, you can see that in this moment the disk reads a lot, because it's doing the same.
2016-08-03 18:33 GMT+02:00 Stephen Russell srussell705@gmail.com:
Does this walk the folder tree and pull the sizes from en-US, etc, SEP, and on and on... totaling all of the sizes combined?
I am guessing that there is no api that does this in Win7 at least. From the explorer I click for Properties of a BIG folder and it takes a few secs to total up all the content. You see it flashing as it updates.
Case in point C:\Windows 46.1 gig for me. YMMV
On Wed, Aug 3, 2016 at 8:21 AM, Fernando D. Bozzo fdbozzo@gmail.com wrote:
Another solution pure VFP here:
? get_DirSize("c:\Windows\System32\drivers")
PROCEDURE get_DirSize LPARAMETERS tcDir EXTERNAL ARRAY taFiles LOCAL laFiles(1), I, lnFiles
IF VARTYPE(pnDirSize) <> "N" PRIVATE pnDirSize pnDirSize = 0 ENDIF tcDir = ADDBS(tcDir) lnFiles = ADIR( laFiles, tcDir + '*.*', 'D', 1) FOR I = 1 TO lnFiles && Look for files IF NOT SUBSTR( laFiles(I,5), 5, 1 ) == 'D' pnDirSize = pnDirSize + laFiles(I,2) ENDIF ENDFOR FOR I = 1 TO lnFiles && Look for Subdirs IF SUBSTR( laFiles(I,5), 5, 1 ) == 'D' AND NOTINLIST(laFiles(I,1),
'.', '..') get_DirSize( tcDir + laFiles(I,1) ) ENDIF ENDFOR
RETURN pnDirSizeENDPROC
2016-08-03 13:43 GMT+02:00 Laurie Alvey trukker41@gmail.com:
You can also use filer.dll like this:
LOCAL oFiler As CFileUtil OF Filer.FileUtil LOCAL i, n, c, o CREATE CURSOR files (fullname V(50), attrib I, bytes I) oFiler = NEWOBJECT("Filer.FileUtil") oFiler.SearchPath = GETDIR() IF EMPTY(oFiler.SearchPath) RETURN ENDIF oFiler.SubFolder = 1 oFiler.FileExpression = "*.*" oFiler.Find(0) n = oFiler.Files.Count IF n > 0 CLEAR FOR i = 1 TO n o = oFiler.Files.Item(i) c = o.Path + o.Name INSERT INTO files VALUES (c, o.Attr, o.Size) ENDFOR ENDIF SUM bytes TO n ? "Total size", CAST(n As B(0))
Laurie
On 2 August 2016 at 12:46, Stephen Russell srussell705@gmail.com
wrote:
Have used this in C# a long time ago.
long length =
Directory.GetFiles(directoryPath,"*",SearchOption.AllDirectories).Sum(t
=> (new FileInfo(t).Length));
On Tue, Aug 2, 2016 at 12:58 AM, Fernando D. Bozzo <
fdbozzo@gmail.com>
wrote:
Yeah, I know, but I tend to find optimization and speed. It's the same as using "select * into cursor" just for looking the
_tally
El 2/8/2016 7:40, "Gérard LOCHON" g-lochon@wanadoo.fr escribió:
> Generally, it's multipurpose > > > Le 02/08/2016 à 00:56, Fernando D. Bozzo a écrit : > >> I think that creating a cursor and is too much for something
that
only
>> need >> to sum file lenghts. >> Can be done with 2 arrays, one needed for ADIR and one for
keeping
the
>> paths and subtotals. >> >> >
[excessive quoting removed by server]
just a test to check if my posts get there - I didn't show on the stats, and Google drops my copy of my posts so I don't have that confirmation.
Andy:
I checked the archives, and your last (and ONLY July) post was 7/27:
http://leafe.com/archives/msg/504990
On Tue, Aug 2, 2016 at 9:53 AM, AndyHC andy@hawthorncottage.com wrote:
just a test to check if my posts get there - I didn't show on the stats, and Google drops my copy of my posts so I don't have that confirmation.
[excessive quoting removed by server]
Your test was a Success - we now know you truly exist!
Regards, Kurt Wendt Senior Systems Analyst
Tel. +1-212-747-9100 www.GlobeTax.com
-----Original Message----- From: ProfoxTech [mailto:profoxtech-bounces@leafe.com] On Behalf Of AndyHC Sent: Tuesday, August 02, 2016 9:54 AM To: profoxtech@leafe.com Subject: test...
just a test to check if my posts get there - I didn't show on the stats, and Google drops my copy of my posts so I don't have that confirmation.
[excessive quoting removed by server]