コード例 #1
0
ファイル: ModItem.cs プロジェクト: vlad1000/ModioX
        /// <summary>
        /// Download mods archive to the specified local folder path
        /// </summary>
        /// <param name="categoriesData"></param>
        /// <param name="downloadFiles"></param>
        /// <param name="localPath">Path to downloads mods archive at folder</param>
        public void DownloadArchiveAtPath(CategoriesData categoriesData, DownloadFiles downloadFiles, string localPath)
        {
            string zipFileName = $"{StringExtensions.ReplaceInvalidChars(Name)} v{Version} for {GameId.ToUpper()}.zip";
            string zipFilePath = Path.Combine(localPath, zipFileName);

            GenerateReadMeAtPath(categoriesData, DownloadDataDirectory(downloadFiles));

            using WebClient webClient = new WebClient();
            webClient.Headers.Add("Accept: application/zip");
            webClient.Headers.Add("User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)");
            webClient.DownloadFile(new Uri(downloadFiles.URL), zipFilePath);
            Archives.AddFilesToZip(zipFilePath, new string[] { Path.Combine(DownloadDataDirectory(downloadFiles), "README.txt") });
        }
コード例 #2
0
ファイル: ModsData.cs プロジェクト: ohhsodead/AtomicX
            /// <summary>
            ///     Download mods archive to the specified local folder path
            /// </summary>
            /// <param name="localPath">Path to downloads mods archive at folder</param>
            public void DownloadArchiveAtPath(string localPath)
            {
                string zipFileName = StringExtensions.ReplaceInvalidChars(string.Format("{0} v{1}.zip", Name, Version));
                string zipFilePath = Path.Combine(localPath, zipFileName);

                GenerateReadMeAtPath(GetDownloadDataPath());

                using (WebClient wc = new WebClient())
                {
                    wc.Headers.Add("Accept: application/zip");
                    wc.Headers.Add("User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)");
                    wc.DownloadFile(new Uri(Url), zipFilePath);
                }

                Archives.AddFilesToZip(zipFilePath, new string[] { Path.Combine(GetDownloadDataPath(), "README.txt") });
            }