private static void GetLatestVersion(string path)
 {
     try
     {
         var folder = Path.GetDirectoryName(path);
         FileSystem.FileSystem.Local.Directory.Ensure(folder);
         var downloadUrl    = WebRequestHelper.DownloadString(BaseUrl + "download.txt");
         var packageZipPath = Path.Combine(folder, "package.zip");
         WebRequestHelper.DownloadFile(downloadUrl, packageZipPath);
         FileSystem.FileSystem.Local.Zip.UnpackZip(packageZipPath, folder);
     }
     catch (Exception ex)
     {
         WindowHelper.HandleError("Couldn't get latest version of Sitecore ConfigBuilder", true, ex, typeof(ConfigBuilderButton));
     }
 }
        public void DownloadFile(Uri url, string fileName, long fileSize, string localRepository, string cookies, CancellationToken token)
        {
            using (var response = WebRequestHelper.RequestAndGetResponse(url, null, null, cookies))
            {
                var destFileName = Path.Combine(localRepository, fileName);
                Assert.IsTrue(!FileSystem.FileSystem.Local.File.Exists(destFileName), "The {0} file already exists".FormatWith(destFileName));

                if (this.TryCopyFromExternalRepository(fileName, destFileName))
                {
                    this.Controller.IncrementProgress(fileSize);
                    return;
                }

                WebRequestHelper.DownloadFile(url, destFileName, response, token, count => this.Controller.IncrementProgress(count));
            }
        }
示例#3
0
 private void GetLatestVersion(string path)
 {
     try
     {
         var folder = Path.GetDirectoryName(path);
         FileSystem.FileSystem.Local.Directory.Ensure(folder);
         var downloadTxtUrl = BaseUrl.TrimEnd('/') + "/download.txt";
         var downloadUrl    = WebRequestHelper.DownloadString(downloadTxtUrl).TrimEnd(" \r\n".ToCharArray());
         var packageZipPath = Path.Combine(folder, "package.zip");
         WebRequestHelper.DownloadFile(downloadUrl, packageZipPath);
         FileSystem.FileSystem.Local.Zip.UnpackZip(packageZipPath, folder);
     }
     catch (Exception ex)
     {
         WindowHelper.HandleError("Couldn't get latest version of " + AppName, true, ex);
     }
 }