Inheritance: IInstallablePackage
Beispiel #1
0
        async Task InstallUrls(Manifest manifest, ManifestPackage package)
        {
            string dir   = Path.GetDirectoryName(manifest.FileName);
            string path  = Path.Combine(dir, package.Path).Replace("\\", "/");
            var    files = new List <string>();

            var urlPackage = new UrlPackage
            {
                Name  = package.Name,
                Files = files
            };

            OnInstalling(manifest, urlPackage, path);

            foreach (string url in package.Urls)
            {
                string fileName = Path.GetFileName(url);
                string filePath = new FileInfo(Path.Combine(dir, package.Path, fileName)).FullName;
                Directory.CreateDirectory(Path.GetDirectoryName(filePath));

                files.Add(fileName);

                using (WebClient client = new WebClient())
                {
                    OnCopying(url, filePath);
                    await client.DownloadFileTaskAsync(url, filePath);

                    OnCopied(url, filePath);
                }
            }

            OnInstalled(manifest, urlPackage, path);
        }
Beispiel #2
0
        async Task InstallUrls(Manifest manifest, ManifestPackage package)
        {
            string dir = Path.GetDirectoryName(manifest.FileName);
            string path = Path.Combine(dir, package.Path).Replace("\\", "/");
            var files = new List<string>();

            var urlPackage = new UrlPackage
            {
                Name = package.Name,
                Files = files
            };

            OnInstalling(manifest, urlPackage, path);

            foreach (string url in package.Urls)
            {
                string fileName = Path.GetFileName(url);
                string filePath = new FileInfo(Path.Combine(dir, package.Path, fileName)).FullName;
                Directory.CreateDirectory(Path.GetDirectoryName(filePath));

                files.Add(fileName);

                using (WebClient client = new WebClient())
                {
                    OnCopying(url, filePath);
                    await client.DownloadFileTaskAsync(url, filePath);
                    OnCopied(url, filePath);
                }
            }

            OnInstalled(manifest, urlPackage, path);
        }