Error in Getting FTP File Size

Hello,

I need help on this issue ASAP. I am trying to download a file from my UNIX FTP Server by using Aspose.Network. Before I start downloading file I am trying to get the size of the file by using GetFileSize function. But, it throws an exception with message: Failed to get file size! The stack trace does not give any hint why is that happening. First I thought it might be a connection problem, and then I commented this line and it downloads the file with no problem. So it has to be something wrong in this function. Can someone from Aspose team take a look on this, Please! Thanks very much. Here is the stack trace of the exception:

Aspose.Network.Ftp.FtpException: Failed to get file size :550 SIZE: Operation not permitted

at Aspose.Network.Ftp.FtpClient.GetFileSize(String remoteFilePath)

at FTPDownloadAndDelete.FTP.DownloadFTPFile() in myproject.vb:line 218

By the way, it works fine with Windows 2003 FTP server, it throws this exception ONLY on UNIX FTP server

Thanks very much,

Pulkit Zery

Dear Pulkit Zery,

Could you please tell me what’s version of Aspose.Network are you using? It looks like this bug is being fixed in previous release.

The latest version of Aspose.Network is 2.3.1.0. Please check it out.

http://www.aspose.com/Community/Files/53/aspose.barcode/category1082.aspx

Let me know if it works.

Thanks,

Hello,

Thanks for the reply, I have the latest version of Aspose.Network (version 3.5.2.0) which is the most recent one on the website. And I verified that the GetFileSize function works fine with windows FTP servers and throws the exception if try to get file size on UNIX FTP servers. So, its gotta be a bug in that function. Please increase the priority of this issue, because we are trying to push our application’s next release ASAP. I appreciate your understanding into this matter. Thanks very much.

By the way, the link and the latest version you provided is for Aspose.Barcode.

Best regards,

Pulkit Zery

Dear Pulkit Zery,

Thanks for your reply.

Could you please tell me what UNIX ftp server are you using? Is it possible to provide an account for our debugging? My mailbox is guangzhou$$aspose.com. If you can provide us a ftp account for debugging, send it to my email.

In addition, could you please try to use the follow code to see if it works? We have resolved some bugs relative to GetSize in Unix. I know whether it can help or not.

string ftpServer = @"ftp1.at.proftpd.org";
FtpClient client = new FtpClient(ftpServer);
client.Connect(true);
client.ResetTransferType(TransferType.Binary);
long size = client.GetFileSize(@"memtest86.img");
Console.WriteLine(size);

Thanks,

Hello,

Thanks for the reply. I have asked our service provider about the UNIX FTP question you had, and they gonna get back to me some time later today, I will update you with the information about what type of server it is, later today.

I have opened an account so that you can troubleshoot the problem and debug into it. I am gonna send it to your email, once you done please let me know so that I can close the account.

I am using the exact same function you said to see if works. Here is the VB.NET code that I am using:

Dim WithEvents moFTP As New FtpClient

'Connect to FTP server!
Me.moFTP = New FtpClient("ServerName", "UserName", "Password")
Me.moFTP.TransferType = TransferType.Binary
moFTP.Connect(True)

'Make sure that the file exists on FTP server!
If Not Me.moFTP.Exists(RemotePath) Then
    Me.moFTP.Disconnect()
    Exit Sub
End If

'Get the File Size -> THIS LINE THROWS EXCEPTION
Dim miRemoteFileSize As Long = Me.moFTP.GetFileSize(RemotePath)

'Download the File
Me.moFTP.Download(sRemotePath, sLocalPath, True)

'Disconnect from FTP Server!
Me.moFTP.Disconnect()

Again, thanks very much for your help, I look forward to see it working! Thanks.

Pulkit Zery

Dear Pulkit Zery,

Thanks for your reply.

We have got the solution. Please check it out.

Add this line,

Me.moFTP.ResetTransferType(TransferType.Binary);

For the Unix Ftp Server, we need to reset the TransferType before getting the size of the files. It is a ftp server application specified command.

Thanks

[Code]

Dim WithEvents moFTP As New FtpClient

'Connect to FTP server!

Me.moFTP = New FtpClient("ServerName", "UserName", "Password")

Me.moFTP.TransferType = TransferType.Binary

moFTP.Connect(True)

'Make sure that the file exists on FTP server!

If Not Me.moFTP.Exists(RemotePath) Then

Me.moFTP.Disconnect()

Exit Sub

End If

//add this for Unix Ftp

Me.moFTP.ResetTransferType(TransferType.Binary);

'Get the File Size -> THIS LINE THROWS EXCEPTION

Dim miRemoteFileSize As Long = Me.moFTP.GetFileSize(RemotePath)

'Download the File

Me.moFTP.Download(sRemotePath, sLocalPath, True)

'Disconnect from FTP Server!

Me.moFTP.Disconnect()

Hello,

Thanks for the reply. I tested and IT WORKS like charm! Thanks for your time its really appreciative.

Best regards,

Pulkit Zery