// upload the file
client.PutFile("file.txt", "/file.txt.part");
// rename it
client.Rename("/file.txt.part", "/file.txt");
// upload the file
client.PutFile("file.txt", "/incoming/file.txt");
// move it
client.Rename("/incoming/file.txt", "/file.txt");
// upload process...
// create empty file .lock indicating the file is being transferred
client.PutFile(new MemoryStream(), "/file.txt.lock");
// upload the file
client.PutFile("file.txt", "/file.txt");
// remove the .lock file to indicate the transfer is completed
client.DeleteFile("/file.txt.lock");
// download process...
// wait until the file is complete
// note: adding some timeout check is needed to prevent deadlock in case
// the upload process failed and the .lock file remains on server
while (client.FileExists("/file.txt.lock"))
Thread.Sleep(1000);
// download the file
client.GetFile("/file.txt", "file.txt");