C# Class NSoft.NFramework.Networks.FtpClient

.NET 2.0 FtpWebRequest, FtpWebResponse를 이용한 FTP Client Class
Show file Open project: debop/NFramework Class Usage Examples

Public Methods

Method Description
CreateDirectory ( string remoteDir ) : bool

지정된 경로를 생성한다. (다중 폴더도 생성합니다. 예 : "/사용자/배성혁/개발 자료" )

DeleteDirectory ( string remoteDir ) : bool

지정된 FTP 경로의 Dirctory를 제거한다.

DeleteDirectory ( string remoteDir, bool recursive ) : bool

지정된 FTP 경로 및 하위 디렉토리도 모두 제거한다.

DeleteFile ( string remoteFilename ) : bool

FTP 서버에 있는 파일을 삭제한다.

DirectoryExists ( string directory ) : bool

서버의 모든 디렉토리를 찾는다.

Download ( FtpFileInfo remoteFI, FileInfo localFI, bool canOverwrite = false ) : bool

Download ( FtpFileInfo remoteFI, string localFilename, bool canOverwrite = false ) : bool

FTP 원격파일을 다운로드 받는다.

Download ( string remoteFilename, FileInfo localFI, bool canOverwrite = false ) : bool

FTP 원격 파일을 지정한 로칼 파일로 저장한다.

Download ( string remoteFilename, Stream localStream ) : bool

원격 파일을 다운받아 지정된 스트림에 쓴다.

Download ( string remoteFilename, string localFilename, bool canOverwrite = false ) : bool

원격 파일을 다운 받아 로칼 파일로 저장한다.

ExtractPath ( string remoteFilename ) : string

FTP 파일 전체경로에서 파일이름 부분을 뺀 경로만 가져온다.

FileExists ( string remoteFilename ) : bool

FTP 서버에 지정된 파일이 있는지 검사한다.

FtpClient ( ) : System

Initialize a new instance of NSoft.NFramework.Networks.Ftp.FtpClient class.

FtpClient ( string hostname, string username = null, string password = null ) : System

Initialize a new instance of NSoft.NFramework.Networks.Ftp.FtpClient class with ftp host name and login account information.

GetFileSize ( string remoteFilename ) : long

지정된 원격 파일의 크기를 가져온다.

ListDirectory ( ) : ICollection

현재 디렉토리의 서브 디렉토리 이름만 가져온다.

ListDirectory ( string directory ) : ICollection

지정한 디렉토리의 서브 디렉토리 이름만 가져온다.

ListDirectory ( string directory, List paths, bool recursive ) : void

하위 폴더도 포함하여 디렉토리 목록을 빌드하여 paths에 추가한다.

ListDirectoryDetail ( ) : FtpDirectory

현재 디렉토리의 서브 디렉토리의 정보를 가져온다.

ListDirectoryDetail ( string directory ) : FtpDirectory

지정한 디렉토리의 서브 디렉토리의 정보를 가져온다.

RenameFile ( string srcFilename, string destFilename ) : bool

FTP 서버에 있는 파일명을 변경합니다. NOTE: .NET 4.0에서는 버그가 있습니다. http://stackoverflow.com/questions/4159903/problem-renaming-file-on-ftp-server-in-net-framework-4-0-only/5897531#5897531

Upload ( FileInfo fi ) : bool

지정된 로칼 파일을 FTP의 현재 디렉토리에 같은 파일명으로 전송한다.

Upload ( FileInfo fi, string remoteFilename ) : bool

지정된 로칼 파일을 FTP 서버에 지정된 파일명으로 저장한다.

Upload ( Stream localStream, string remoteFilename ) : bool

지정된 스트림 정보를 FTP서버에 지정된 파일명으로 저장한다.

Upload ( string localFilename ) : bool

지정된 로칼 파일을 FTP의 현재 디렉토리에 같은 파일명으로 전송한다.

Upload ( string localFilename, string remoteFilename ) : bool

지정된 로칼 파일을 FTP 서버에 지정된 파일명으로 저장한다.

Private Methods

Method Description
AdjustDir ( string path ) : string

FTP 경로 형식에 맞게 '/' 로 시작하고 끝의 '/' 는 제거한다.

AdjustRemoteFilename ( string remoteFilename ) : string

원격 파일명으로 FTP 전체 경로가 포함된 파일 경로로 만든다.

GetCredentials ( ) : ICredentials

네트웍 사용자 인정 정보

GetDirectory ( ) : string

현재 디렉토리의 전체 경로를 URI 형식으로 얻는다.

GetDirectory ( string dir ) : string

지정된 디렉토리의 전체 경로를 URI 형식으로 얻는다.

GetDownloadResponseStream ( string uri ) : Stream

FtpWebResponse의 ResponseStream을 얻는다.

GetFullPath ( string file ) : string

현재 디렉토리를 기준으로 지정된 파일명의 전체 경로를 가져온다.

GetRequest ( string uri ) : FtpWebRequest

지정된 URI에 대한 Ftp Request 객체를 생성한다.

GetSize ( WebRequest request ) : long

FTP 요청에 대한 응답의 크기를 구한다.

GetUploadRequestStream ( string uri ) : Stream

FtpWebRequest의 RequestStream을 얻는다.

ListDirectoryInternal ( string directory, string command ) : string

지정된 디렉토리의 엔트리 정보를 가져온다.

PathCombine ( string path1, string path2 ) : string

FTP 두개의 경로를 합한다.

SendRequest ( WebRequest request ) : string

FTP 서버로부터 응답을 받아, 문자열로 변환하여 반환한다.

FTP 서버들은 대부분 문자열 반환에 개행문자로 CRLF (MS-DOS 스타일) 를 쓰지 않고, CR (UNIX 스타일) 만을 보낸다. 문자열을 MS-DOS 스타일로 사용하고 싶으면 CR을 CRLF로 변환한 후 사용해야한다.

SendRequestOnly ( FtpWebRequest request ) : void

FTP로 요청을 보낸다. 응답을 받지만 파싱하지는 않는다.

Method Details

CreateDirectory() public method

지정된 경로를 생성한다. (다중 폴더도 생성합니다. 예 : "/사용자/배성혁/개발 자료" )
public CreateDirectory ( string remoteDir ) : bool
remoteDir string
return bool

DeleteDirectory() public method

지정된 FTP 경로의 Dirctory를 제거한다.
public DeleteDirectory ( string remoteDir ) : bool
remoteDir string
return bool

DeleteDirectory() public method

지정된 FTP 경로 및 하위 디렉토리도 모두 제거한다.
public DeleteDirectory ( string remoteDir, bool recursive ) : bool
remoteDir string remote directory name to delete
recursive bool delete sub directories with recursive.
return bool

DeleteFile() public method

FTP 서버에 있는 파일을 삭제한다.
public DeleteFile ( string remoteFilename ) : bool
remoteFilename string
return bool

DirectoryExists() public method

서버의 모든 디렉토리를 찾는다.
public DirectoryExists ( string directory ) : bool
directory string 검색할 디렉토리 (예 : "/Users/Debop")
return bool

Download() public method

public Download ( FtpFileInfo remoteFI, FileInfo localFI, bool canOverwrite = false ) : bool
remoteFI FtpFileInfo 원격 파일 정보
localFI System.IO.FileInfo 로칼 파일 정보
canOverwrite bool 겹쳐쓰기 여부
return bool

Download() public method

FTP 원격파일을 다운로드 받는다.
public Download ( FtpFileInfo remoteFI, string localFilename, bool canOverwrite = false ) : bool
remoteFI FtpFileInfo 원격 파일 정보
localFilename string 로칼 파일 전체 경로
canOverwrite bool 겹쳐쓰기 여부
return bool

Download() public method

FTP 원격 파일을 지정한 로칼 파일로 저장한다.
public Download ( string remoteFilename, FileInfo localFI, bool canOverwrite = false ) : bool
remoteFilename string 원격 파일 전체 경로 (예: /Users/debop/readme.txt)
localFI System.IO.FileInfo 로칼 파일 정보
canOverwrite bool 겹쳐쓰기 여부
return bool

Download() public method

원격 파일을 다운받아 지정된 스트림에 쓴다.
public Download ( string remoteFilename, Stream localStream ) : bool
remoteFilename string 원격 파일 전체 경로 (예: /Users/debop/readme.txt)
localStream Stream 원격파일 정보를 저장할 Stream 객체
return bool

Download() public method

원격 파일을 다운 받아 로칼 파일로 저장한다.
public Download ( string remoteFilename, string localFilename, bool canOverwrite = false ) : bool
remoteFilename string 원격 파일 전체 경로 (예: /Users/debop/readme.txt)
localFilename string 로칼 파일 전체 경로
canOverwrite bool 겹쳐쓰기 여부
return bool

ExtractPath() public method

FTP 파일 전체경로에서 파일이름 부분을 뺀 경로만 가져온다.
public ExtractPath ( string remoteFilename ) : string
remoteFilename string FTP 서버의 파일 경로
return string

FileExists() public method

FTP 서버에 지정된 파일이 있는지 검사한다.
public FileExists ( string remoteFilename ) : bool
remoteFilename string
return bool

FtpClient() public method

Initialize a new instance of NSoft.NFramework.Networks.Ftp.FtpClient class.
public FtpClient ( ) : System
return System

FtpClient() public method

Initialize a new instance of NSoft.NFramework.Networks.Ftp.FtpClient class with ftp host name and login account information.
public FtpClient ( string hostname, string username = null, string password = null ) : System
hostname string ftp server host name
username string login username
password string login password
return System

GetFileSize() public method

지정된 원격 파일의 크기를 가져온다.
public GetFileSize ( string remoteFilename ) : long
remoteFilename string
return long

ListDirectory() public method

현재 디렉토리의 서브 디렉토리 이름만 가져온다.
public ListDirectory ( ) : ICollection
return ICollection

ListDirectory() public method

지정한 디렉토리의 서브 디렉토리 이름만 가져온다.
public ListDirectory ( string directory ) : ICollection
directory string UNIX 스타일의 경로
return ICollection

ListDirectory() public method

하위 폴더도 포함하여 디렉토리 목록을 빌드하여 paths에 추가한다.
public ListDirectory ( string directory, List paths, bool recursive ) : void
directory string
paths List
recursive bool
return void

ListDirectoryDetail() public method

현재 디렉토리의 서브 디렉토리의 정보를 가져온다.
public ListDirectoryDetail ( ) : FtpDirectory
return FtpDirectory

ListDirectoryDetail() public method

지정한 디렉토리의 서브 디렉토리의 정보를 가져온다.
public ListDirectoryDetail ( string directory ) : FtpDirectory
directory string
return FtpDirectory

RenameFile() public method

FTP 서버에 있는 파일명을 변경합니다. NOTE: .NET 4.0에서는 버그가 있습니다. http://stackoverflow.com/questions/4159903/problem-renaming-file-on-ftp-server-in-net-framework-4-0-only/5897531#5897531
public RenameFile ( string srcFilename, string destFilename ) : bool
srcFilename string 원본 파일명
destFilename string 변경할 파일명
return bool

Upload() public method

지정된 로칼 파일을 FTP의 현재 디렉토리에 같은 파일명으로 전송한다.
public Upload ( FileInfo fi ) : bool
fi System.IO.FileInfo
return bool

Upload() public method

지정된 로칼 파일을 FTP 서버에 지정된 파일명으로 저장한다.
public Upload ( FileInfo fi, string remoteFilename ) : bool
fi System.IO.FileInfo
remoteFilename string
return bool

Upload() public method

지정된 스트림 정보를 FTP서버에 지정된 파일명으로 저장한다.
public Upload ( Stream localStream, string remoteFilename ) : bool
localStream Stream
remoteFilename string
return bool

Upload() public method

지정된 로칼 파일을 FTP의 현재 디렉토리에 같은 파일명으로 전송한다.
public Upload ( string localFilename ) : bool
localFilename string file to upload
return bool

Upload() public method

지정된 로칼 파일을 FTP 서버에 지정된 파일명으로 저장한다.
public Upload ( string localFilename, string remoteFilename ) : bool
localFilename string
remoteFilename string
return bool