Hi all - I may be encountering the same issue with directories, otherwise its an untrapped usage error.
In ScpClient.NET.cs:
private void InternalUpload(ChannelSession channel, PipeStream input, DirectoryInfo directoryInfo, string directoryName)
{
this.InternalSetTimestamp(channel, input, directoryInfo.LastWriteTimeUtc, directoryInfo.LastAccessTimeUtc);
this.SendData(channel, string.Format("D0755 0 {0}\n", directoryName));
this.CheckReturnCode(input);
...
The same 'unexpected filename' error is caught in CheckReturnCode. I might be talking toss here, since I don't know the SSH protocol, but I think that SendData D0755 instruction doesn't like a full path since it works if I supply a single directory name, without slashes, but I everything ends up in my home directory.
This quick rework seems to be okay:
privatevoid InternalUpload(ChannelSession channel, PipeStream input, DirectoryInfo sourceDirectoryInfo, string destinationDirectoryPath) {this.InternalSetTimestamp(channel, input, sourceDirectoryInfo.LastWriteTimeUtc, sourceDirectoryInfo.LastAccessTimeUtc);this.SendData(channel, string.Format("D0755 0 {0}\n", Path.GetFileName(destinationDirectoryPath)));this.CheckReturnCode(input);// Upload filesvar sourceFiles = sourceDirectoryInfo.GetFiles();foreach (var sourceFile in sourceFiles) {string destinationPath = Path.Combine(destinationDirectoryPath, sourceFile.Name).Replace(@"\", @"/");this.InternalUpload(channel, input, sourceFile, destinationPath); }// Upload directoriesvar sourceDirectories = sourceDirectoryInfo.GetDirectories();foreach (var sourceDirectory in sourceDirectories) {string destinationPath = Path.Combine(destinationDirectoryPath, sourceDirectory.Name).Replace(@"\", @"/");this.InternalUpload(channel, input, sourceDirectory, destinationPath); }this.SendData(channel, "E\n");this.CheckReturnCode(input); }