How to calculate size of FTP folder? Do you know any tool or programmatic way in C#?
Then look at the queue pane and below it (on the status bar) you should see a message indicating the queue size. Very good solution. This way, you can get the total number of files and the total size without Downloading any file. The FTP command used by Filezilla is MLSD (recursively) if anybody is curious about it.
Go to Windows Explorer and right-click on the file, folder or drive that you're investigating. From the menu that appears, go to Properties. This will show you the total file/drive size. A folder will show you the size in writing, a drive will show you a pie chart to make it easier to see.
FTP Get Default Directory is a synchronous activity that retrieves the name of the current remote directory. The default remote directory is operating system dependent and determined by the remote FTP server.
Calculate Size can be found under menu Options/Preferences and then click Transfer and look to the Common Options-area.
If you have FileZilla, you can use this trick:
Add files to queue
This will scan all folders and files and add them to the queue. Then look at the queue pane and below it (on the status bar) you should see a message indicating the queue size.
You can use the du
command in lftp
for this purpose, like this:
echo "du -hs ." | lftp example.com 2>&1
This will print the current directory's disk size incl. all subdirectories, in human-readable format (-h
) and omitting output lines for subdirectories (-s
). stderr output is rerouted to stdout with 2>&1
so that it is included in the output.
However, lftp
is a Linux-only software, so to use it from C# under Windows you would need to install it in the integrated Windows Subsystem for Linux (WSL) or using Cygwin or MSYS2. (Thanks to the commenters for the hints!)
The lftp du
command documentation is missing from its manpage, but available within the lftp shell with the help du
command. For reference, I copy its output here:
lftp :~> help du Usage: du [options] <dirs> Summarize disk usage. -a, --all write counts for all files, not just directories --block-size=SIZ use SIZ-byte blocks -b, --bytes print size in bytes -c, --total produce a grand total -d, --max-depth=N print the total for a directory (or file, with --all) only if it is N or fewer levels below the command line argument; --max-depth=0 is the same as --summarize -F, --files print number of files instead of sizes -h, --human-readable print sizes in human readable format (e.g., 1K 234M 2G) -H, --si likewise, but use powers of 1000 not 1024 -k, --kilobytes like --block-size=1024 -m, --megabytes like --block-size=1048576 -S, --separate-dirs do not include size of subdirectories -s, --summarize display only a total for each argument --exclude=PAT exclude files that match PAT
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With