1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
// Variable membre de ta classe
bool fileCompleted = false;
// À mettre dans le procédure où tu télécharge tes fichiers uns à uns
m_oWebClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(m_oWebClient_DownloadProgressChanged);
foreach(FileInfo oFileInfo in m_oFileList)
{
m_oWebClient.DownloadFileAsync(m_ftpAddress + "\\" + oFileInfo.Name, "c:\\" + oFileInfo.Name, oFileInfo);
while (!fileCompleted)
{
System.Threading.Thread.Sleep(30);
}
// Ton fichier à été complèté ici !
// Remettre ton flag à false pour l'autre fichier à télécharger
fileCompleted = false;
}
private void m_oWebClient_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{
// Récupération de ton object FileInfo founis avant le téléchargement
FileInfo file = (FileInfo)e.UserState;
// Ici tu as ton progress avec e.BytesReceived ou e.TotalBytesToReceive
}
private void m_oWebClient_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
{
// Récupération de ton object FileInfo founis avant le téléchargement
FileInfo file = (FileInfo)e.UserState;
fileCompleted = true; ;
} |
Partager