c# - 如何在没有其他 Nuget 包的情况下打开 zip 文件?
问题描述
我有以下代码:
public static class PracticeFunction
{
[FunctionName("LearningAboutFunctions")]
public static void Run([TimerTrigger("0 */5 * * * *")]TimerInfo myTimer, ILogger log)
{
log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");
using (var client = new WebClient())
{
client.DownloadFile("https://examplesite.co.uk/file.zip", "myfile.zip");
}
}
}
}
有没有一种方法可以打开 Zip 文件并提取内容而无需安装任何额外的 nuget 包?
解决方案
尝试这样的事情
using System.IO.Compression;
string startPath = @"C:\Users\host\Desktop\Folder";
string zipPath = startPath + @"\Zipfile.zip";
string extractPath = @"C:\Users\host\Desktop\Final Folder\";
ZipFile.ExtractToDirectory(zipPath, extractPath);
推荐阅读
- php - 使用“AWS Cloudfront”CDN 配置时,“搜索”选项在“Wordpress”中不起作用
- javascript - 如何使用 axios 将数组发送到服务器
- python - Django 中的登录和身份验证
- html - 摆脱未知的溢出 CSS
- reactjs - react native expo 在我的手机上不起作用我可以在同一个 wifi 下做
- npm - 无法安装 Netlify cms 插件 Gatsby
- node.js - 定义条带订阅发票是否有效的限制
- c++ - 如何在 C++ 中修复这个计算器错误?
- javascript - 无法在 Electron 中打开 PDF 文件
- python - 如何高效地创建多维数组?