FluentFTP 추가
This commit is contained in:
41
FileTransfer.cs
Normal file
41
FileTransfer.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user