Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to calculate size of directory on FTP?

Tags:

c#

ftp

How to calculate size of FTP folder? Do you know any tool or programmatic way in C#?

like image 871
jlp Avatar asked Jul 02 '10 09:07

jlp


People also ask

How do I see the size of an FTP folder?

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.

How do you determine size of folder?

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.

What is directory in FTP?

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.

How do I find the size of a directory in Winscp?

Calculate Size can be found under menu Options/Preferences and then click Transfer and look to the Common Options-area.


2 Answers

If you have FileZilla, you can use this trick:

  • click on the folder(s) whose size you want to calculate
  • click on 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.

like image 136
janusman Avatar answered Sep 18 '22 07:09

janusman


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 
like image 39
tanius Avatar answered Sep 20 '22 07:09

tanius