1

Closed

sftpClient and Exists method

description

I have wrote this simple test in MsTest:
    [TestMethod]
    public void TestExist()
    {
        // arrange
        var filename = "filename.txt";
        var file = new MemoryStream(this.GetBytes("This is a test"));

        var cl = new SftpClient(configurator.Object.AppSettings["ftpServerURL"],
            configurator.Object.GetIntValueFromAppSettings("ftpPortNumber"),
            configurator.Object.AppSettings["ftpUsername"],
            configurator.Object.AppSettings["ftpPassword"]);
        cl.Connect();
        cl.UploadFile(file, filename);

        // act
        var result = cl.Exists(filename);

        // assert
        Assert.AreEqual(true, result);
    }

    private byte[] GetBytes(string str)
    {
        byte[] bytes = new byte[str.Length * sizeof(char)];
        System.Buffer.BlockCopy(str.ToCharArray(), 0, bytes, 0, bytes.Length);
        return bytes;
    }
Though the file is correctly uploaded to the FTP the assertion is not verified. Why?
Closed Sep 17, 2016 at 8:45 AM by drieseng
If you can still reproduce this issue with version 2016.0.0 (or higher) of SSH.NET, then please submit at our new home.

comments