이 코드를 가지고 있지만 그것은 작동하지 않습니다는 ...FTP 다운로드 BackgroundWorker에
ProgressBar를 움직되지 않고 다운로드 한 파일의 크기는 0킬로바이트입니다.
내 WHILE 루프에 문제가 있다고 생각합니다. 이 문제를 어떻게 해결할 수 있습니까? 나에게 지침을주세요!
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
DirectoryInfo folder= new DirectoryInfo(@"C:\Cloud24");
try
{
{
long size= 0;
WebClient request = new WebClient();
request.Credentials = new NetworkCredential(userid, userpass);
FileStream file = File.Create(folder+ "//" + downloadname);
byte[] filedata = request.DownloadData(ftpadress + "/" + downloadname);
while ((size= file.Read(filedata, 0, filedata.Length)) > 0)
{
file.Write(filedata, 0, filedata.Length);
size += (int)filedata.Length;
double dProgressPercentage = ((double)(size)/(double)filedata.Length);
backgroundWorker1.ReportProgress((int)(dProgressPercentage * 100));
}
file.Close();
MessageBox.Show(downloadname + " downloaded!" +
Environment.NewLine + "There: " + folder);
}
}
catch (Exception exc)
{
MessageBox.Show("Error: " + exc.Message);
}
}
디버깅을 시도 했습니까? – CloudyMarble
예! 벌써 –
을 debuged하면서 그 동안 루프 안에 들어가는거야? – CloudyMarble