Hi,
I am trying to get multiple files from a server using FtpClient.Get(theDestination, theSource) and place them on my hard drive. I tried to loop through particular files on the server and kept getting an error;
System.IO.IOException: The process cannot access the file "c:\logTest\sample04.txt" because it is being used by another process.
at System.IO.__Error.WinIOError(Int32 errorCode, String str)
at System.IO.FileInfo.Delete()
at EnterpriseDT.Net.Ftp.FTPClient.GetASCII(String localPath, String remoteFil
e)
at EnterpriseDT.Net.Ftp.FTPClient.Get(String localPath, String remoteFile)
at ftpTest.Class1.Main(String[] args) in c:\csharp_snippets\ftpcsharp\test01\
ftptest\class1.cs:line 52
why am i getting this error? Below are pieces of code i used....
...
ftp = new FTPClient(host);
ftp.Login(user, password);
ftp.ConnectMode = FTPConnectMode.PASV;
ftp.TransferType = FTPTransferType.ASCII;
//...
for(i = 0; i < 25; i++)
{
ftp.Get(@"c:\logTest\"+destFile[i], @"/myServer/"+sourceFile[i]);
ftp.TransferCompleteEx += new TransferHandler(ftp_TransferCompleteEx);
}
//...
private static void ftp_TransferCompleteEx(object sender, TransferEventArgs e)
{
Console.WriteLine("--------------------------------");
Console.WriteLine("File Transfer Complete");
Console.WriteLine("--------------------------------\n\n");
}
it works for some of the iterations, but i get the error around the 4th iteration.
cheers,