I'm getting the files in a dir. For each file a transfer that file to my local disk and then deleting it on the ftp server.
My question is: What happens if somebody tries to write to a file, that I'm trying to delete? How can I prevent this? Is it possible to lock the dir while I do my job and unlock it again when I'm finished?
Here is my code:
FTPClient ftpClient = new FTPClient(address);
ftpClient.Login(userName,password);
ftpClient.Chdir(remoteDir);
string[] files = ftpClient.Dir();
foreach(string elm in files) {
ftpClient.Get(localDir+elm,elm);
ftpClient.Delete(elm);
}
ftpClient.Quit();
Ulrik