Example #1
0
 public string DownloadText(string url)
 {
     using (var streamReader = new StreamReader(urlStreamReader.OpenStream(url)))
     {
         return(streamReader.ReadToEnd());
     }
 }
Example #2
0
 public void DownloadFile(string url, string targetPath)
 {
     using (Stream sourceStream = urlStreamReader.OpenStream(url))
         using (Stream targetStream = new FileStream(targetPath, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.None))
         {
             sourceStream.CopyTo(targetStream);
         }
 }
 public Task <List <VersionInfo> > GetLatestVersionInfo()
 {
     return(Task.Factory.StartNew(() =>
     {
         var stream = urlStreamReader.OpenStream(versionFileUrl);
         var versionInfos = (List <VersionInfo>)VersionInfoSerializer.Value.Deserialize(stream);
         // Do some post-processing by replacing string arguments ("{0}", "{1}") with the appropriate content
         // This is supported so that maintaining version.xml is easier,
         // i.e. the version number needs to be changed in fewer places
         foreach (var versionInfo in versionInfos)
         {
             versionInfo.FileName = string.Format(versionInfo.FileName, versionInfo.LatestVersion);
             versionInfo.DownloadUrl = string.Format(versionInfo.DownloadUrl,
                                                     versionInfo.LatestVersion, versionInfo.FileName);
         }
         return versionInfos;
     }));
 }