LogicLancer
Newbie
- Oct 30, 2023
- 7
- 2
0
I get a list of attributes (filename, size and date) from a sftp client but I need to automatically insert that list into a SQL Server table. I have been able to connect to the database via Visual studio but now I have no idea how to insert that list into a database table. please help!!!!
Here is my c sharp code that lists the attributes
I get a list of attributes (filename, size and date) from a sftp client but I need to automatically insert that list into a SQL Server table. I have been able to connect to the database via Visual studio but now I have no idea how to insert that list into a database table. please help!!!!
Here is my c sharp code that lists the attributes
Code:
public static void Main()
{
string host = @"sftp.com";
string username = "myusername";
string password = @"mypassword";
string remoteDirectory = " ";
using SftpClient sftp = new SftpClient(host, username, password);
{
try
{
sftp.Connect();
var files = sftp.ListDirectory(".");
foreach (var file in files)
{
Console.WriteLine(file.Name);
SftpFile f = sftp.Get(file.Name);
Console.WriteLine(f.Attributes.Size);
Console.WriteLine(f.Attributes.LastWriteTime);
}
sftp.Disconnect();
}
catch (Exception e)
{
Console.WriteLine("An exception has been caught " + e.ToString());
}