|
|
|
@ -1,12 +1,19 @@
@@ -1,12 +1,19 @@
|
|
|
|
|
using System.Collections.Generic; |
|
|
|
|
using System.IO; |
|
|
|
|
using FluentFTP; |
|
|
|
|
|
|
|
|
|
namespace EGFramework{ |
|
|
|
|
public class EGFtpSave : IEGSave, IEGSaveFile |
|
|
|
|
{ |
|
|
|
|
public void InitSave(string path) |
|
|
|
|
public FtpClient FTPClient { set; get; } |
|
|
|
|
|
|
|
|
|
public void InitSave(string host) |
|
|
|
|
{ |
|
|
|
|
throw new System.NotImplementedException(); |
|
|
|
|
this.FTPClient = new FtpClient(host); |
|
|
|
|
} |
|
|
|
|
public void InitUser(string user, string password) |
|
|
|
|
{ |
|
|
|
|
this.FTPClient.Credentials = new System.Net.NetworkCredential(user, password); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void CopyFile(string sourcePath, string copyPath) |
|
|
|
@ -34,14 +41,19 @@ namespace EGFramework{
@@ -34,14 +41,19 @@ namespace EGFramework{
|
|
|
|
|
throw new System.NotImplementedException(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public IEnumerable<IEGFileMsg> ListLocalFilePath(string localPath) |
|
|
|
|
public IEnumerable<IEGFileMsg> ListRemoteFilePath(string remotePath) |
|
|
|
|
{ |
|
|
|
|
throw new System.NotImplementedException(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public IEnumerable<IEGFileMsg> ListRemoteFilePath(string remotePath) |
|
|
|
|
{ |
|
|
|
|
throw new System.NotImplementedException(); |
|
|
|
|
FTPClient.Connect(); |
|
|
|
|
FtpListItem[] nameList = FTPClient.GetListing(remotePath); |
|
|
|
|
List<IEGFileMsg> fileList = new List<IEGFileMsg>(); |
|
|
|
|
foreach (var item in nameList) |
|
|
|
|
{ |
|
|
|
|
IEGFileMsg fileMsg = new EGFileMsg(); |
|
|
|
|
fileMsg.Init(item.Name, item.Type == FtpObjectType.Directory, item.FullName, item.Size/1024, item.Modified); |
|
|
|
|
fileList.Add(fileMsg); |
|
|
|
|
} |
|
|
|
|
FTPClient.Disconnect(); |
|
|
|
|
return fileList; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void MakeDirectory(string remotePath) |
|
|
|
@ -61,7 +73,9 @@ namespace EGFramework{
@@ -61,7 +73,9 @@ namespace EGFramework{
|
|
|
|
|
|
|
|
|
|
public void SyncFile(string remotePath, string localPath) |
|
|
|
|
{ |
|
|
|
|
throw new System.NotImplementedException(); |
|
|
|
|
FTPClient.Connect(); |
|
|
|
|
FTPClient.DownloadFile(localPath, remotePath, FtpLocalExists.Overwrite); |
|
|
|
|
FTPClient.Disconnect(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void UploadFile(FileStream localFileStream, string remotePath) |
|
|
|
@ -71,7 +85,9 @@ namespace EGFramework{
@@ -71,7 +85,9 @@ namespace EGFramework{
|
|
|
|
|
|
|
|
|
|
public void UploadFile(string localPath, string remotePath) |
|
|
|
|
{ |
|
|
|
|
throw new System.NotImplementedException(); |
|
|
|
|
FTPClient.Connect(); |
|
|
|
|
FTPClient.UploadFile(localPath, remotePath, FtpRemoteExists.Overwrite, true, FtpVerify.Retry); |
|
|
|
|
FTPClient.Disconnect(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |