5

I want to upload files to home (root) directory of the server, not into a folder.

How can I do it? (using C#)

transferResult = session.PutFiles(path, "\\", true, transferOptions);

If I use \\ for remotePath, uploaded file was renamed.

0

1 Answer 1

11

Remote paths typically use Unix convention with forward-slashes, not Windows back-slashes.

Moreover using a slash only denotes a root folder, not a home folder (unless your account is chrooted).

Ideally use an absolute path to the home folder:

session.PutFiles(path, "/home/user/", ...);

For chrooted account that would be a slash only (this is a general comment, I see it's not your case):

session.PutFiles(path, "/", ...);

You can also use the "./" to refer to an initial (home) directory.

session.PutFiles(path, "./", ...);

You can also use the Session.HomePath:

session.PutFiles(path, session.HomePath + "/", ...);
Sign up to request clarification or add additional context in comments.

1 Comment

Awesome that the author of WinSCP is here answering questions. Probably part of the reason it works so well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.