【问题标题】:Zip file download corruptedZip 文件下载损坏
【发布时间】:2018-03-31 05:22:06
【问题描述】:

我在下载“.zip”文件时遇到问题。我想做一个游戏启动器,我需要添加游戏下载和安装功能。当我从服务器下载带有ZipFile.DownloadFile 的打包游戏时,它被损坏了。

这是代码:

using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Net;

// Installation folder will be set in the folder browse dialog
string installationFolder;

// I don't want to show the download url but its in Mediafire 
// and I tried to download it from Google Drive
string remoteUri = "the .zip file url";
string fileName = "gamename.zip", myStringWebResource = null;

// Create a new WebClient instance.
WebClient myWebClient = new WebClient();

// Concatenate the domain with the Web resource filename.
myStringWebResource = remoteUri + fileName;

// Download the Web resource and save it into the current filesystem folder.
myWebClient.DownloadFile(remoteUri, Application.StartupPath + "/gamesdownload/" + fileName);

ZipFile.ExtractToDirectory(Application.StartupPath + "/gamesdownload/gamename.zip", installationFolder);

代码有什么问题?

【问题讨论】:

  • 删除了 Visual Studio 2017 标签
  • “但它在 Mediafire 中” - 如果您获取 zip 文件的链接并在隐身/私密浏览会话中打开它会发生什么?我怀疑您实际上是在下载面向人类的重定向页面。如果不是这种情况,那么您应该使用VBinDiff 之类的工具将预期的 zip 文件与下载的 zip 文件进行比较。
  • 你可以分享链接,以便我们看看它是否有效?
  • 好的,我们可以得到一个minimal reproducible example
  • @Marakusa 你不能尝试下载另一个压缩包,它可能对你不那么敏感,你可能愿意与我们分享?

标签: c# file download zip


【解决方案1】:

找到答案了! 我从 Mediafire 变成了 GitHub! 这是出现错误的解决方案: The request was aborted: Could not create SSL/TLS secure channel

【讨论】:

    猜你喜欢
    • 2018-03-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多