I am using the latest Aspose.Network DLL and when I call the method GetFileSize() it throws the exception:
"Failed to get file size :550 SIZE: Operation not permitted"
If I load AceFTP, it can read the file sizes on the ftp server, so I'm guessing this must be an issue on your end. The ftp server is running UNIX if that helps you at all.
This is causing issues with our customer in a live environment, so a quick response is appreciated!
Could you give us more detail about the problem you mention? We tried to reproduce the problem. But it looks ok. You can get the file size by full path, or change the working folder and give the file name only. Check it out.
Please double check your code, if you have changed the working folder to the subfolder which contains the file, use the file name to invoke the GetFileSize; Or perhaps, give the full path of the file from the root.
_ftp and _currentFileSize are class level objects. This code I am using has been working for some time now and stopped working just recently, so it is possible that it is an issue with our hosts server.
One question they asked me is "What command are you using when you receive the file size error?". So I ask this question to you...what command is being sent to the ftp server when the method GetFileSize is called? I assume it is simply the SIZE command, but please correct me if I am wrong.
I did some searching on the Internet and found the following information that may help fix this issue.
Our ftp host is using ProFTPd as the server software, and that particular software needs to have the SIZE command set in binary mode. I don't think this is something that I can change via a property, so could you look into this and see if you can fix this in your code? I tried ftp.transferType.Binary, but that didn't work, as I expected it wouldn't.
Sorry, I am unable to send you the ftp account information as it is private. Did my last post about sending the SIZE command in Binary mode make any sense?
Could you give the folder structure in your Ftp server, and print out what is the parameter value provided to the GetFileSize function?
As I posted on the 1st post, I concerned about whether the root is the path of the file, instead of the Size command. Could you please double-check that?
We are still working on this issue. I will get back to your as soon as possible.
Ok, as I mentioned before, this had been working and I have not changed anything, so I don't think that it has anything to do with the way my code is written. The FTP struture is:
/myRoot/mySubDir/[file name]
The value provided to the GetFileSize function is a string containing the filename.
_ftp.GetFileSize("myfile.txt")
I am not trying to issue the SIZE command, as that is in your underlying code.
From what I have found searching on this issue, I still think that our best bet is to make sure the command type is set to BINARY before issuing the SIZE command. Can you please let me know if this is happening or not? Also, please test against a ProFTPd server running version 1.3.0 if possible, as that is what my host is running.
We have reproduced this problem using a ProFTPd ftp server. Your previous post is right. ProFTPd does not support SIZE command properly.
By TYPE command (set the transfermode to Binary), However, we get the trick to make the SIZE command work. I will fix it in the coming hotfix of Aspose.Network, which does not expose sending out the TYPE command now.
I will provide the hotfix later the day.
Thanks very much.
Appendix:
Here is my ftp command line to the ProFTPd server. Check it out.
TYPE A 200 Type set to A SIZE memtest86.img 550 SIZE: Operation not permitted TYPE I 200 Type set to I SIZE memtest86.img 213 1440 TYPE A 200 Type set to A SIZE memtest86.img 550 SIZE: Operation not permitted TYPE I 200 Type set to I SIZE memtest86.img 213 1440
I downloaded and installed the hotfix and now I am now receiving a different error message, and earlier in my application. I create a new ftp client and then connect. After connecting I call the ChangeDirectory Function and I get the following error:
Aspose.Network.Ftp.FtpException was unhandled Message="Receive command failed:" Source="Aspose.Network" StackTrace: at Aspose.Network.Ftp.x3db11afbf84d4caa.xa05aa2ced21a423b() at Aspose.Network.Ftp.x3db11afbf84d4caa.xc5abe82d115f9b3e() at Aspose.Network.Ftp.FtpClient.ChangeDirectory(String remotePath) at VTSApp.Downloader.tmrDownload_Tick(Object sender, EventArgs e) at System.Windows.Forms.Timer.OnTick(EventArgs e) at System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData) at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.Run(Form mainForm) at VTSApp.Login.Main() at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args) at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args) at System.Runtime.Hosting.ManifestRunner.Run(Boolean checkAptModel) at System.Runtime.Hosting.ManifestRunner.ExecuteAsAssembly() at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[] activationCustomData) at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart()
I'm not sure where to go from here. Here is the code I am using. The error occurs on the last line.
If Not _ftp.Connected Then
_ftp = New Aspose.Network.Ftp.FtpClient("www.myhost.com", "username", "password")
_ftp.Connect(True)
End If
_ftp.ChangeDirectory("/mydir/mysubdir") 'Error occurs here
FYI, I tried to do a ResetTransferType before the call to ChangeDirectory, and I got the exact same error message that I did when I tried to change directories, only it gave the exception on the "ResetTransferType" line.
So I've done a bit more digging and I found that it was getting that error the 2nd time through the loop. The root error appears to be caused due to the TransferBroken event getting called. The BrokenException message is:
"Stream does not support seeking."
I'm not sure what that means, so hopefully you'll be able to help me out. I've done some web searching, but haven't come up with anything helpful.
Here's the order of things.
Create a new FTP instance
Connect to the ftp server
Change the directory
Start Async download by calling BeginDownload method
TransferBroken callback is invoked with the BrokenException message set to the error above.
I've tried to download different files, but the above sequence is what always happens. Hopefully this additional info will help track down the issue.
I rolled my DLL back to the latest release version (3.5.1) and commented out the SIZE code and I am still getting the error above. Please check into why your current release code would cause a TransferBroken exception when downloading Async from Proftpd 3.0.
We have a client waiting on this, so please respond ASAP. Also, what hours (in Central Time) are you actually around? If I know, I can try to work on it while you can respond to me faster.
Sorry for all of the posts, but I thought of one more thing. I tried a Synch download and it started working, but then eventually ended up throwing the "Stream does not support seeking" error in the TransferBroken event.
Maybe each little bit I give you will help solve the problem faster. :)
I'm sorry for not replying your quickly. Could you please send your code to us for the further debugging? I cannot repro your problems under our environment. It is great if you can share some of your code that uses the Ftp component.
Furthermore, please use this dll for your testing. Let me know if you get any exception on it.
Thanks for the updated hotfix, but that didn't solve anything. The transfer is still being broken and the BrokenException Message is still "Stream does not support seeking". I have attached my code file.