42 lines
1.0 KiB
C#
42 lines
1.0 KiB
C#
using FluentFTP;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace AutoSellerNS
|
|
{
|
|
class FileTransfer
|
|
{
|
|
const string HOST = "mjjo53.us.to";
|
|
const string USER = "trader";
|
|
const string PASSWORD = "sbtmaoao";
|
|
const string REMOTE_BASE_PATH = "/";
|
|
|
|
public async void SendDir(string localDir, string remoteDir)
|
|
{
|
|
try
|
|
{
|
|
using (FtpClient client = new FtpClient(HOST, USER, PASSWORD))
|
|
{
|
|
client.ConnectTimeout = 3000;
|
|
client.RetryAttempts = 3;
|
|
|
|
string project_path = Path.GetDirectoryName(Path.GetDirectoryName(System.IO.Directory.GetCurrentDirectory()));
|
|
List<string> files = Directory.GetFiles(project_path + localDir).ToList();
|
|
string remotePath = REMOTE_BASE_PATH + remoteDir;
|
|
await client.ConnectAsync();
|
|
await client.UploadFilesAsync(files, remotePath, FtpExists.Overwrite);
|
|
//await client.ChmodAsync(remotePath, 777);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Console.WriteLine(ex);
|
|
}
|
|
}
|
|
}
|
|
}
|