반응형
try{
int _count = 0;
foreach (string _str in downFileName)//파일명
{
bar = this.progressBar;//파일이 존재하는 ftp파일 주소
Uri ftpUri = new Uri(@"ftp://주소");
//file size
FtpWebRequest reqFtp = (FtpWebRequest)WebRequest.Create(ftpUri);
reqFtp.Method = WebRequestMethods.Ftp.GetFileSize;
reqFtp.Credentials = new NetworkCredential();
FtpWebResponse resFtp = (FtpWebResponse)reqFtp.GetResponse();
fileSize = resFtp.ContentLength;
resFtp.Close();
_count++;
using (WebClient wclient = new WebClient())
{
wclient.Credentials = new NetworkCredential();
wclient.DownloadProgressChanged += request_DownloadProgressChanged;
//다운로드 될떄마다 불리는 함수
wclient.DownloadFileCompleted += new AsyncCompletedEventHandler(Completed);
//다운로드 시작
//ftpUri : ftp 주소, _fpath : 다운받을 주소, _str : 다운 받을 폴더 이름
wclient.DownloadFileAsync(ftpUri, _fpath + "\\" + _str);
}
}
}
catch (Exception e){
MessageBox.Show("DownLoad 함수 error : " + e.Message + "\n\n" + e.ToString());
}
반응형
'IT > C#, NHibernate' 카테고리의 다른 글
| [C#] string 문자열 가운데 공백 제거 (1) | 2011.08.17 |
|---|---|
| [C#] thread 에서 UI 변수에 접근하는 방법 (0) | 2011.08.17 |
| [C#] alt+tab 해도 안보이게하기 (0) | 2011.07.18 |
| [C#] 프로그램 종료 시키기 (0) | 2011.07.05 |
| [C#] 윈폼 배경화면 (0) | 2011.06.22 |