Hari Krishna

Hari Krishna

  • NA
  • 129
  • 47.8k

sftp server upload file

May 11 2023 11:55 AM

FileInfo f=new FileInfo("C:\\mdu\\abcd.xml");            
string uploadfile=f.FullName;    
Console.WriteLine(f.Name);
Console.WriteLine("uploadfile"+uploadfile);
var client = new SftpClient(host, port, username, password);
client.Connect();
if(client.IsConnected){
       Console.WriteLine("I AM CONNECTED");
}
var fileStream = new FileStream(uploadfile, FileMode.Open);  
if(fileStream!=null){
            Console.WriteLine("YOU ARE NOT NULL");
}
client.BufferSize = 4 * 1024; 
client.UploadFile(fileStream, f.Name,null);
client.Disconnect();
client.Dispose();


Answers (3)