示例#1
0
        /// <summary>
        ///		Descarga los archivos
        /// </summary>
        public async Task DownloadFilesAsync()
        {
            var webClient = new LibCommonHelper.Communications.HttpWebClient();

            // Descarga los eventos
            foreach (MediaFileModel file in Files)
            {
                string fileName = GetDownloadFileName(file);

                // Descarga el archivo
                if (!string.IsNullOrEmpty(fileName) && !File.Exists(fileName))
                {
                    // Lanza el evento de descarga
                    RaiseEvent(file, Files.IndexOf(file), Files.Count);
                    // Crea el directorio
                    HelperFiles.MakePath(Path.GetDirectoryName(fileName));
                    // Descarga el archivo
                    try
                    {
                        // Descarga el archivo
                        await webClient.DownloadFileAsync(file.Url, fileName);

                        // Asigna el nombre del archivo descargado
                        file.FileName = fileName;
                    }
                    catch {}
                }
            }
            // Lanza el evento de fin
            EndDownload?.Invoke(this, EventArgs.Empty);
        }
示例#2
0
 private void _RaiseEndDownload(bool isCanceled) => EndDownload?.Invoke(this, new UpdateDownloadEventArgs(isCanceled));