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 <[email protected]> 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 pnDirSize
> ENDPROC
>
>
> 2016-08-03 13:43 GMT+02:00 Laurie Alvey <[email protected]>:
>
> > 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 <[email protected]>
> 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 <[email protected]>
> > > 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" <[email protected]> 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]

_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: 
http://leafe.com/archives/byMID/profox/CAJidMYKiSY4v_1-WCujPvUsVfhoE+JDUL1X3e4rfzBnJ=a1...@mail.gmail.com
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to