06-23-2016 08:29 AM
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
06-23-2016 09:57 AM
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 disponibiliI'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! ![]()
06-23-2016 10:05 AM
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,
06-23-2016 10:15 AM
You can issue the command using LaunchExecutable () or System () , then parse the output file with File I/O functions.
06-24-2016 01:46 AM
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.
04-05-2020 09:13 PM
thanks a lot!~