本文整理汇总了C#中System.Net.WebClient.CopyTo方法的典型用法代码示例。如果您正苦于以下问题:C# System.Net.WebClient.CopyTo方法的具体用法?C# System.Net.WebClient.CopyTo怎么用?C# System.Net.WebClient.CopyTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Net.WebClient
的用法示例。
在下文中一共展示了System.Net.WebClient.CopyTo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
public override bool Execute() {
if (!NeedsUpdate()) return true;
try {
var ms = new MemoryStream();
var downloadStream = new System.Net.WebClient().OpenRead(Url);
downloadStream.CopyTo(ms);
ms.Seek(0, SeekOrigin.Begin);
var hash = new SHA256Managed().ComputeHash(ms);
if (BitConverter.ToString(hash).Replace("-", "").ToLower() != this.Hash) {
Log.LogError("Got wrong hash for {0}", Url);
return false;
}
try {
Directory.Delete(Root, true);
}
catch (DirectoryNotFoundException) {
// Obviously not an issue
}
ms.Seek(0, SeekOrigin.Begin);
var bzStream = new ICSharpCode.SharpZipLib.BZip2.BZip2InputStream(ms);
var tarStream = new ICSharpCode.SharpZipLib.Tar.TarInputStream(bzStream);
while (true) {
TarEntry entry = tarStream.GetNextEntry();
if (entry == null) break;
ExtractEntry(Root, entry, tarStream);
}
File.WriteAllText(Path.Combine(Root, "aegisub.hash"), Hash);
return true;
}
catch (Exception e) {
Log.LogErrorFromException(e);
return false;
}
}