I have been working on a small project in C # to upload XML files to an sftp server to a folder called "input". I was only able to do it with one file, and I need to upload all the files from a local repository, please help :(
var info = new SftpInfo()
{
Destination = @"./input/",
Host = "subir.org",
UserName = "admin1",
Password = "1234",
Port = 222
};
try
{
using (SftpClient client = new SftpClient(info.Host, info.Port, info.UserName, info.Password))
{
client.Connect();
client.ChangeDirectory(info.Destination);
using (FileStream fs = new FileStream(@"D:/Archivos/archivo76781_P026977.xml", FileMode.Open))
{
client.BufferSize = 4 * 1024;
client.UploadFile(fs, Path.GetDirectoryName(@"D:/Archivos/archivo76781_P026977.xml"));
Console.WriteLine("successfully");
Console.WriteLine("*************************************");
}
}
}
catch (Exception ex)
{
Console.WriteLine("An Error has Occured: " + ex);
Console.WriteLine("Hay un error");
}