| Dart Home | PowerTCP FTP for .NET | Custom Development | Reply | PowerTCP FTP for .NET Topics | Forums |
| Author | Forum: PowerTCP FTP for .NET Topic: FTP Put not being allowed to complete |
| cconoboy From: Coppell, TX USA Posts: 2 Member Since: 11/19/04 |
posted November 19, 2004 12:12 PM The following code issue that I am having is that when in debug this code works fine, but when run straight from an exe is does not post the files. From the testing I have done it appears that it is not keeping the connection open long enought for the ftp to complete. Anyone have any suggestions? static bool FTPFile(string sZipName) { bool bSuccess = false; FtpFileStatus sStatus = FtpFileStatus.TransferInProgress; Dart.PowerTCP.SecureFtp.Ftp oFTP = new Dart.PowerTCP.SecureFtp.Ftp(); oFTP.Server = "ftp.server.com"; oFTP.Username = "User"; oFTP.Password = "Pass"; oFTP.Passive = false; oFTP.FileType = Dart.PowerTCP.SecureFtp.FileType.Image; Dart.PowerTCP.SecureFtp.FtpFile file; try { string sFileName = new System.IO.FileInfo(sZipName).Name; file = oFTP.Put(sZipName, "/Inbound/" + sFileName); while(file.Position < file.Length) { } if (file.Status == FtpFileStatus.TransferCompleted) { bSuccess=true; else { bSuccess=false; } } catch(Exception ex) { bSuccess=false; } if (oFTP.Connected) { try {oFTP.Close();} catch {oFTP.Abort();} } return bSuccess; } |
Tony Priest![]() From: Utica, NY USA Posts: 8466 Member Since: 04/11/00 |
posted November 19, 2004 12:21 PM What is the exact exception that you get? Which line of code triggers it? Also, please explain the following code: while(file.Position < file.Length) { } What if file.Position < file.Length? This would be an infinite loop. |
| cconoboy From: Coppell, TX USA Posts: 2 Member Since: 11/19/04 |
posted November 19, 2004 12:28 PM There is no error, it completes but does not push the file. Also this is not an infinite loop. From the definitions in the help: FtpFile.Position A long representing the current position within the stream/file. FtpFile.Length A long representing the length of the file. I am not married to that line of code but was doing anything to get the thing to delay it's close, it is suppose to be synch, but does not appear to be waiting for the transfer to complete before it goes to the next line of code after the put. Again I am not getting an error, it just closes the connection as if it were complete but in debug works fine, same code and test files. |
Tony Priest![]() From: Utica, NY USA Posts: 8466 Member Since: 04/11/00 |
posted November 19, 2004 12:40 PM The Put method is blocking, so after it returns file.Position will never change. Therefore this: while(file.Position < file.Length) { } would cause a loop if for some reason file.Position < file.Length. I can't think why that would be but I also can't think of a reason for having that code in the first place. Please remove all that unneeded code after the call to put. Then check file.Exception to see if it is set after the transfer. That's where any errors would be. If you are still having trouble, try running one of the samples and see what happens. |
| Reply | PowerTCP FTP for .NET Topics | Forums |
This site is powered by
PowerTCP WebServer for ActiveX
|