Quantcast
Channel: sshnet Discussions Rss Feed
Viewing all articles
Browse latest Browse all 1729

New Post: SFTP: Uploading Files to the FTP Server has Inconsistent Behavior

$
0
0
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.

Viewing all articles
Browse latest Browse all 1729

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>