Q:

How to download and open XML file via SFTP?

I need to open XML file (create XmlDocument) without creating local copy. Using SSH.NET, I came up with this code:
var connectionInfo = new ConnectionInfo("host",
    "username",
    new PasswordAuthenticationMethod("username", "password"));

using (var client = new SftpClient(connectionInfo))
{
    client.Connect();

    System.IO.MemoryStream mem = new System.IO.MemoryStream();

    client.DownloadFile("filename.xml", mem);

    mem.Position=0;

    using(XmlReader reader = XmlReader.Create(mem))
    {
        var docc = new XmlDocument();
        docc.Load(mem);
    }

    client.Disconnect();
}

But is gets stuck on docc.Load(mem). What could be the problem?
mem object looks like this:

A:

Note that here:
using(XmlReader reader = XmlReader.Create(mem))
{
    var docc = new XmlDocument();
    docc.Load(mem);
}

You are not using variable reader at all. Either change to
using(XmlReader reader = XmlReader.Create(mem))
{
    var docc = new XmlDocument();
    docc.Load(reader);
}

or remove reader at all:
docc.Load(mem);

