SftpPathNotFound - Creating directory then uploading file

Mar 29, 2016 at 7:16 PM
I have the following issue where I create directory to the client I want to upload files (windows host/linux guest) then proceed to upload the file and it returns a SftPathNotFoundException. Only if I catch the exception and retry the file upload will it pass.

Assume the following path exists on the guest machine /home/abc/xyz, my code
string path = "/home/abc/xyz/child"

if(!client.Exist(path))
  client.CreateDirectory(path)

//proceed to upload file to newly created path
client.UploadFile(some_file_stream,path + "'\\" + some_file_name)
This will result in SftPathNotFoundException unless I catch it and retry the above.