IT정보공유/C#

[C#] FluentFTP 를 이용한 FTP Client File Upload, File Download 방법

알지오™ 2019. 8. 6.


NuGet에서 FTP Client 라이브러리를 찾아보니 FluentFTP 라는게 있더군요.
꽤 많은 개발자들이 사용하고 있는것 같고, 사용법도 간결하고 sftp나 ssl 등도 지원하고 쓸만한것 같습니다.

아래 소스코드는 업로드 샘플입니다.
(업로드시 디렉토리가 없으면 생성)
            

bool bUpload = false; 
bool bDownload = false;

FtpClient ftp = new FtpClient(FTPHost, FTPPort), FTPId, FTPPw); 

ftp.RetryAttempts = 3; 

bUpload = ftp.UploadFile(LocalFile, UploadPath + "/" + UploadFileName, FtpExists.Overwrite, true); 


bDownload = ftp.DownloadFile(LocalFile, DownloadPath + "/" + DownloadFileName, FtpExists.Overwrite, true); 

ftp.Disconnect(); 


FtpExists.Overwrite 속성은 FTP 에 있는 파일을 삭제하고, 업로드 하는 방식이라
FTP 계정에 삭제 권한이 있어야 하니 참고 하시기 바랍니다.

아래는 NuGet에 소개된 FluentFTP의 설명입니다.
An FTP and FTPS client for .NET & .NET Standard, optimized for speed. 
Provides extensive FTP commands, File uploads/downloads, SSL/TLS connections, 
Automatic directory listing parsing, File hashing/checksums, 
File permissions/CHMOD, FTP proxies, UTF-8 support, Async/await support and more. 
Written entirely in C#, with no external dependencies.

댓글

💲 추천 글