Skip to content

UploadDirectory in ScpClient.Net #81

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Psilax opened this issue Sep 7, 2016 · 5 comments
Closed

UploadDirectory in ScpClient.Net #81

Psilax opened this issue Sep 7, 2016 · 5 comments
Assignees
Milestone

Comments

@Psilax
Copy link

Psilax commented Sep 7, 2016

I was testing the uploading of whole directories with ScpClient using the Upload(DirectoryInfo directoryInfo, string Path) function (ScpClient.NET.cs)

My example uploads c:\temp\configuration to /home/root
I was expecting to get the content of my local folder in /home/root/configuration
but it ended up in /home/root/root

What I think is the faulty line is
SendData(channel, string.Format("D0755 0 {0}\n", Path.GetFileName(path)));
I believe it should be:
SendData(channel, string.Format("D0755 0 {0}\n", directoryInfo.Name));

@drieseng
Copy link
Member

I did some tests myself, and I don't see any issues.

I created the following local directory structure:

c:\temp\foo\file1
c:\temp\foo\file2
c:\temp\foo\sub1\file1
c:\temp\foo\sub1\file2
c:\temp\foo\sub2

I created the following remote directory:

/home/sshnet/test

I then used the following code to perform the upload:

using (var client = new ScpClient(connectionInfoFactory.Create()))
{
    client.Connect();
    client.Upload(new DirectoryInfo(@"c:\temp\foo"), "/home/sshnet/test");
}

I ended up with the following remote result:

/home/sshnet/test
/home/sshnet/test/file1
/home/sshnet/test/file2
/home/sshnet/test/sub1/file1
/home/sshnet/test/sub1/file2
/home/sshnet/test/sub2

Please share more about your local directory structure, the code you used to upload and the remote result.

@drieseng drieseng self-assigned this Sep 25, 2016
@drieseng drieseng added this to the 2016.1.0 milestone Dec 14, 2016
@drieseng
Copy link
Member

Not sure why I couldn't reproduce this issue before, but this week I stumbled onto this issue myself.
I submitted issue #128 for this.

This should be fixed in version 2016.1.0-beta1.
Please test and provide feedback.

@Psilax
Copy link
Author

Psilax commented Jan 10, 2017

I'll try to test it today, sorry for the delay, but was hectic here at work the past months.

@Psilax
Copy link
Author

Psilax commented Jan 10, 2017

It works, I had to change my function call because in the past i used something like:

UploadDirectory("c:\temp\configurationfiles", "/etc") and then expect it the folder to be created on the target, while the functionality actually is that it will copy the content of the directory instead of the directory .

@drieseng
Copy link
Member

drieseng commented Oct 1, 2017

Fixed by issue #128.

@drieseng drieseng closed this as completed Oct 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants