LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

[CVI 2013] How can I get a folder size ?

Hello,

 

How can I get a folder size to display on CVI ?  (This folder contain many sub-folder and many files).

In my application, The user select a folder, then he should see the size of the selected folder in the interface.

 

Thanks in advance,

Houssam 

 

0 Kudos
Message 1 of 6
(3,654 Views)

Unorthodox, dirty and nasty answer: let the system do the work for you!

Launch a "dir . /s >> dir.txt" command, open the output file dir.txt and in the last-but-one line you'll find the figure you want!

 

On my system the command took <2sec to create a 67500+ lines file on a heavily nested subtree, with this output:

 Il volume nell'unit… C è Acer
 Numero di serie del volume: ******

 Directory di c:\Temp

23/06/2016  16:46    <DIR>          .
23/06/2016  16:46    <DIR>          ..
03/10/2014  12:16            25,614 20141003 stato MAX.nce
24/03/2016  14:44             1,383 20160324 Errore Norton.txt

...

25/03/2015  10:39             5,871 Verifica stampe - 256.pdf
03/02/2015  10:32             5,870 Verifica stampe.pdf
               5 File         28,227 byte

     Totale file elencati:
           43832 File 12,132,582,012 byte     << ==== Total subtree size
           10058 Directory  107,969,974,272 byte disponibili

I'm not aware of a single function that does what you want and if I'm to loose my time on a recursive function that scans the path an sums up files and.... I go the nasty way! Smiley Wink



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 6
(3,648 Views)

Yes I undrestund, thank you.

 

Bu how to execute the Cmd instruction, and how can I copy the result to my CVI code ? Do you have an example please ? 

 

Thanks in advance, 

0 Kudos
Message 3 of 6
(3,644 Views)

You can issue the command using LaunchExecutable () or System () , then parse the output file with File I/O functions.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 4 of 6
(3,641 Views)

A little correction: I suggest to use the command "dir . /s > dir.txt" that regenerates the output file each time, while ">>" command appends data to existing content if the file already exists.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 5 of 6
(3,626 Views)

thanks a lot!~

0 Kudos
Message 6 of 6
(1,881 Views)