User (Old forums)MemberApril 1, 2009 at 1:34 pmPost count: 23064
I am using the FtpClient to receive a file from a remote server. Some times when the file is being received, the connect may get timed out or disconnected for other reasons. With my file only partially downloaded, I cannot seem to do anything with it (delete it, move it, rename it, etc.) I get a message that the file is being used by another process.
It appears as though my application has some sort of lock on the file. How can I make sure that all FtpClient resources are free of any hold on this file? While receiving the file I am catching any exception, so that seems like a good place to free any hold on the file by the FtpClient instance.
Applies to Xceed FTP for .NET. Imported from legacy forums. Posted by Chris (had 3257 views)User (Old forums)MemberApril 2, 2009 at 3:54 pmPost count: 23064
FtpClient closes all its streams, so this should not be a problem.
Can you provide a code snippet on how you do things, so we can try to reproduce the issue, and investigate it further?
Applies to Xceed FTP for .NET. Imported from legacy forums. Posted by André (had 2053 views)User (Old forums)MemberJune 11, 2009 at 1:20 pmPost count: 23064
I am still having the problem on ocassion. I’ll include some sample code of what I am doing, but I’ll add a little more explaination first.
My program (a Windows Service) will connect to a remote server, and start to download a file to a local server. During the download the connect may be dropped for any number of reasons (such as command execution timed out). The download is wrapped in a try-catch block which will notify me of a problem then return to the calling code. The partially downloaded file can not be deleted because the operating system thinks another application is using the file. If I stop the service and then restart it, the lock on the file is freed. It is a .NET C# application but the no other part of the application accesses the file unless the download was successfull. That is why I feel it is the Xceed FtpClient that still has a lock on the file.
ftp = new FtpClient();
http://ftp.Timeout = 90;
http://ftp.KeepAliveInterval = 120;
catch (FtpException fe)
ftpMsg = fe.Message;
new FtpClient(); // This was added to see if reinitialization would free the lock.
return (“Error: Lost connection, reason = “ + ftpMsg);
Applies to Xceed FTP for .NET. Imported from legacy forums. Posted by Chris (had 1712 views)User (Old forums)MemberJune 12, 2009 at 9:43 amPost count: 23064
It would be a good idea to add
if( client.Connected )
as the first statement of your if (receiveFailed) block.
Let us know if this suggestion eliminates the file lock.
Applies to Xceed FTP for .NET. Imported from legacy forums. Posted by Ghislain (had 227 views)
- You must be logged in to reply to this topic.