Beispiel #1
0
        /// <summary>
        /// Gets the file and assign methods to events.
        /// </summary>
        /// <param name="path">Specifies the absolute path where the file will be saved</param>
        /// <param name="app">Enumeration type <see cref="TociApp.Managed.AppToInstall"/> representing applications</param>
        /// <param name="completedDownload">Represents the method that will handle the MethodName<see langword="Completed" /> event of an asynchronous operation.</param>
        /// <param name="progress">Represents the method that will handle the <see cref="E:System.Net.WebClient.DownloadProgressChanged" /> event of a <see cref="T:System.Net.WebClient" /></param>
        /// <exception cref="System.IO.DirectoryNotFoundException">The specified path was not found.</exception>
        public void DownloadFile(string path, AppToInstall app,
                                 AsyncCompletedEventHandler completedDownload = null, DownloadProgressChangedEventHandler progress = null)
        {
            if (String.IsNullOrEmpty(path) && !Directory.Exists(path))
            {
                throw new DirectoryNotFoundException("Directory not found or not exist");
            }
            DownloadFile downloadFile = new DownloadFile();

            App[app].DownloadDirectory = path;

            downloadFile.Progress += progress;
            downloadFile.Complate += completedDownload;
            downloadFile.DwnloadFile(path, App[app]);
        }