Can't download and delete in one connection (General questions)
wod:
I am trying to download and delete using one connection. The DeleteFiles() results in a file or directory not found error, but more importantly it is not calling the LoopItemEvent.
I am calling the delete event from the DoneEvent of the download process.
Is it possible to rest the DoneEvent and LoopItemEvent from the download's done event:
sftp1.DoneEvent -= (sftp1_DoneEventDownload);
sftp1.LoopItemEvent -= (sftp1_LoopItemEventDownload);
and then change the events using:
sftp1.LoopItemEvent += new WeOnlyDo.Client.SFTP.LoopDelegate(this.sftp1_LoopItemEventDelete );
sftp1.DoneEvent += new WeOnlyDo.Client.SFTP.DoneDelegate(this.sftp1_DoneDeleteEvent);
I am not resetting sftp1 in any of the steps.
I've seen the code for deleting one file at a time, but like the loop and done approach.
Just can't get part 2 (the delete process to fire.)
Thanks,
Ken
Re: Can't download and delete in one connection
OK - by resetting the sftp1.RemotePath after the download was complete, I was able to delete the files. It was pointing to a file.
Still getting an error after removing all the files from a remote folder, but the options I described before are now working.
Ken
Re: Can't download and delete in one connection
Ken,
what error do you get?
Do you always use full paths for RemotePath argument (starting with / )?
Re: Can't download and delete in one connection
Error message: WeOnlyDo.Exceptions.SFTP.ServerException: Server returned an error: General failure
The loop deletes all the files I need to delete. The delete loop skips sub directories and other skipped files from the download, so I am not sure why this error appears in the DeleteDoneEvent.
I am using full paths for GetFiles() and DeleteFiles() - resetting the remote directory after the GetFiles loop is done.
Thanks,
Ken
Re: Can't download and delete in one connection
Ken,
I think that DeleteFiles eventually tries to remove parent folder. If it still contains subfolders/files, it fails to do so, so error is generated.
Kreso
Re: Can't download and delete in one connection
That makes sense. Even though I test for object type in my loop, perhaps it still tries to delete the parent folder after completing the file delete loop. I am leaving a child folder untouched.
Sounds like I need to switch to the DeleteFile routine instead of the DeleteFiles().
Ken