Can't PUT locked file using Indy FTP

Giganews Newsgroups
Subject: Can't PUT locked file using Indy FTP
Posted by:  Stuart Jones (stuart.jon…
Date: Tue, 2 Jan 2007

Dear all

I'm using Indy 10 (assembly version 1.0.1620.32252) in a Windows Service
written in C# (recently upgraded to .NET 2.0).

The Windows Service retrieves some data as XML, applies an XSLT to produce a
CSV which is saved to the filesystem as a text file. This all works fine.
Problem is that the FTPing is failing with the error "The process cannot
access the file... because it is being used by another process".

Evidently, the file that's been created still has an open handle or some
such, but I don't get an error if, programmatically, I copy the file to
another location or attach it to an e-mail. Should I expect this error? Does
it have anything to do with the Indy component?

Here's the code used for PUTing the file. Any help/advice is greatly

Stuart Jones

FileInfo fi = new FileInfo(Path.Combine(repository, o.OutputFilename));
if (fi.Exists)
  FTP indyFTP = new FTP();
    indyFTP.Host = o.FtpHost;
    indyFTP.Username = o.FtpUsername;
    indyFTP.Password = o.FtpPassword;
    indyFTP.Put(Path.Combine(repository, o.OutputFilename),
o.OutputFilename, false);
  catch (Exception e)
    return String.Format("iExchange Service error: {0} " +
      "when trying to FTP to: {1}. ",
      e.Message, o.FtpHost);