This project is read-only.

SCP : Missing files when using DirectoryUpload

Sep 25, 2012 at 2:25 PM
Edited Sep 25, 2012 at 2:30 PM


I have the following environment:
- Win7 / 64
- .NET 3.5
- MPC-Target :OpenSSH_6.0p1, OpenSSL 1.0.0j 10 May 2012
- SSH.NET commit 19813

I want to upload a directory structure (recursive, depth = 2) from the PC to a MPC based
Linux remote system. The total amount of data is about 8MB with 23 files from
55 bytes to 4MB.

Calling mScp.Upload(new DirectoryInfo(localDir), remoteDir) does not result any
error and the Uploading event shoes uploading all files. But after Upload() returned
There are a random number of missing files on the target (between 1 and 5).

It tried the same with a PC based Linux as target what resulted in the same behaviour
(OpenSSH_5.8p1 Debian-7ubuntu1, OpenSSL 1.0.0e 6 Sep 2011). It seems the
problem is caused anywhere within SSH.NET.

Does anyone have a solution?

I tried to workaround by replacing Upload(new DirectoryInfo(...)) by several single
calls of Upload(new FileInfo(...)). This worked but is too slow for my application.

Oct 24, 2012 at 10:45 AM

I seem to be having the same problem, sometimes there are missing files when using the Upload() method. I would really appreciate a solution, the workaround described here is not feasible for my use-case.

Dec 28, 2012 at 5:45 PM



Does it happens all the time?

How can I recreate this problem?

I just tried to upload multiple directory structure but it worked with no problem.




Jan 7, 2013 at 7:39 AM


thank you for trying to reproduce. I'm using a very simple code fragment:

using (mSsh = new SshClient(address, user, pass))

  using (mScp = new ScpClient(address, user, pass))
    mScp.ErrorOccurred += new EventHandler<Renci.SshNet.Common.ExceptionEventArgs>(mScp_ErrorOccurred);
    mScp.Uploading += new EventHandler<Renci.SshNet.Common.ScpUploadEventArgs>(mScp_Uploading);

    mScp.Upload( new DirectoryInfo(mcLocalDir)
               , mcRemoteDir);

I also played around with reducing the SCP buffersize by e.g. "mScpClient.BufferSize = 8 * 1024;". But it did not change the
problematic behaviour.

Jan 7, 2013 at 6:32 PM


Yea, nothing special there.

And what happens if you try to upload to different servers?

Does it fails there too?


Do you mind send me zipped directory structure that you trying to upload?

Just wondering if I have problem with multiple directory levels or somewhere else.




Feb 27, 2013 at 12:18 PM
Even for my case here, there is nothing special going on. However my directory structure is > 2 levels deep and has about 25MB of files that range from 100KB to 4MB.