How to know the size of files?

Dec 28, 2011 at 2:01 AM

Hello,

I'm using the Alex FTPS Client in a C# Application, and i want to list the files from a FTP Server knowing it's size (in bytes).

Is there any way to do it?

 

I'm doing as follows:

FTPSClient ftpClient = new FTPSClient();
            ftpClient.Connect(
                FTPHost,
                new NetworkCredential(FTPUser, FTPPass),
                ESSLSupportMode.ClearText
                );
ftpClient.SetCurrentDirectory(RemoteFolder);

foreach (DirectoryListItem file in lista)
                    {
                        if (!file.IsDirectory && !file.IsSymLink)                        
                        {
                            // How to know the file size?
                        }
                    }

Coordinator
Dec 28, 2011 at 2:04 PM

Hi,

you can use the GetFileTransferSize(fileName) method.

 

Best,

Alessandro


Coordinator
Jan 2, 2012 at 10:22 PM

Hi,

DirectoryListItem now contains a "Size" attribute with the info obtained during the directory listing, I just committed the update.

Let me know if you need a compiled dll.

 

Best,

Alessandro

 

 

Feb 26, 2012 at 8:59 PM

That's great Alessandro, thanks!

- Daniel

Feb 26, 2012 at 9:36 PM

By the way, would be nice if you commit the last changes and release a new version of the compiled DLL. The project already have a lot of improvements!

Best regards,

Daniel

Jun 7, 2012 at 1:57 PM

Is there any way to get the size of a directory using the library? I'm also developing a C# application and could use this functionality. I wrote a method that recursively navigates a directory and adds all the file sizes up, but it doesn't play nice with certain servers and the connection gets closed.

 

Many thanks

Apr 18, 2013 at 6:24 PM
A new DLL would be very helpful. I just started writing an app and got around to using DirectoryListItem and found out that 1.1.0 doesn't include the Size property so I'm kinda stalled right now.
Jul 25, 2013 at 11:11 AM
Hello,

I'm also very interested by the "Size" attribute from the DirectoryListItem.

Can you tell me when a compiled dll will be available?

Thanks,
Sebastien