Search code examples
.netftpwebrequest

FtpWebRequest - How to compensate file upload when server defaults current directory to something other than / (root)?


When making FTP connections to some servers the server defaults the current directory to some directory other than the root.

For example:

/
  abc
    mno
      xyz

The server might default the connection to "/" root. Other servers might default to "/abc".

When uploading a file ftp://ftp.example.com/abc/mno/xyz/myfile.dat to the xyz directory, the FtpWebRequest returns a 550 when the current directory is something other than "/". i.e. FtpWebRequest is making the path /abc/abc/mno/xyz/filename.dat which isn't a valid path thus the 550.

Is there any special URI syntax that can compenstate for this so that the same URI works for both types of server default connect conditions?

OR is there some property of FtpWebRequest that can be set to make it smarter?


Solution

  • This blog post seems to explain how to resolve the issue.