首页 > 解决方案 > 参数 3:无法从 'bool' 转换为 'System.Text.Encoding'

问题描述

我正在使用System.IO.Compression和使用ZipFile.ExtractToDirectory. 我看到一个人使用 3 个参数,两个字符串和一个布尔值。当我试图准确地复制他所做的事情时,我得到了一个错误。我知道ZipFile可以是编码或布尔值,但我希望它是布尔值。有什么我需要改变的吗?

我正在使用 .NET Framework 4.7.2

这是任何可能认为会有所帮助的人的代码。这也是我正在关注的视频。它有一个他在哪里输入 ZipFile 行的时间戳。https://youtu.be/JIjZQo03YdA?t=420

private void DownloadGameCompletedCallback(object sender, AsyncCompletedEventArgs e)
{
    try
    {
        string onlineVersion = ((Version)e.UserState).ToString();
        ZipFile.ExtractToDirectory(gameZip, rootPath, true);
        File.Delete(gameZip);

        File.WriteAllText(versionFile, onlineVersion);

        VersionText.Text = onlineVersion;
        Status = LauncherStatus.READY;
    }
    catch (Exception ex)
    {
        Status = LauncherStatus.FAILED;
        MessageBox.Show($"Error finishing download: {ex}");
    }
}

标签: c#zipfilelauncher

解决方案


我使用的是 .NET Framework 而不是 .NET Core。对不起,浪费你们的时间了伙计们!我忘记了 .NET Framework 和 .NET Core 是两个完全不同的东西。


推荐阅读