SFTP: Uploading Files to the FTP Server has Inconsistent Behavior

Apr 4, 2013 at 8:23 AM
Method Name: UploadFile()

Issue: Files Uploaded to FTP Server has Inconsistent Behavior

I am trying to upload the file from local path to the ftp server, there is no exceptions in the uploadFile() method , but most of the times files were not uploaded and few times empty file was being uploaded.

Here is my code for uploading a file to the server:
using (var sftp = new SftpClient(sftpHost, user, password))
    {
        sftp.Connect();
        string FilePath = "D:\\CurrentTask\\in\\new.txt";                                         
        string remoteFileName = "/folderName/filename.txt";

        Stream fs = File.OpenRead(FilePath);                
        sftp.UploadFile(fs, remoteFileName);

        sftp.Disconnect();
    }
Could you help me to resolve this issue?

Thanks in Advance.
Coordinator
Apr 4, 2013 at 3:38 PM
Hi,

Do you upload to SFTP of FTP server?

Thanks,
Oleg
Apr 8, 2013 at 8:59 AM
Edited Apr 8, 2013 at 12:22 PM
Hi Oleg,

Yes, i am uploading to the SFTP Server(sftp://xyz.com) using the above code.


Thanks,
Navin
May 13, 2013 at 11:52 AM
Im trying to upload file from my local to unix platform using sftp...any suggestions?? is this powershell script ????