当前位置: 首页 > news >正文

曲靖做网站需要多少钱比较靠谱的网站

曲靖做网站需要多少钱,比较靠谱的网站,c 怎么做网站开发,大气网络公司网站源码压缩包格式,本文主要用于说明如何使用代码 文件或文件夹压缩为 zip压缩包及其解压操作, 下面分两个版本进行实现 1.简单版本 bool DoCompressDirectoryInfo(string folderPath){try{var zipFilePath $"{folderPath}.zip";var directoryInfo …

压缩包格式,本文主要用于说明如何使用代码 文件或文件夹压缩为 zip压缩包及其解压操作,
下面分两个版本进行实现

1.简单版本

   bool DoCompressDirectoryInfo(string folderPath){try{var zipFilePath = $"{folderPath}.zip";var directoryInfo = new DirectoryInfo(zipFilePath);if (directoryInfo.Exists){directoryInfo.Delete();}if (directoryInfo.Parent != null){directoryInfo = directoryInfo.Parent;}System.IO.Compression.ZipFile.CreateFromDirectory(folderPath, zipFilePath, CompressionLevel.Optimal, false);return true;}catch (Exception ex){_logger.LogError(ex, $"压缩文件失败,{folderPath}!");return false;}}

2.第二种复杂版本

帮助类

class FolderCompressor
{public stati  bool DoCompressDirectoryInfo(string folderPath){try{var zipFilePath = $"{folderPath}.zip";FolderCompressor.CompressFolder(folderPath, zipFilePath);return true;}catch (Exception ex){_logger.LogError(ex, $"压缩文件失败,{folderPath}!");return false;}}public static void CompressFolder(string sourceFolderPath, string destinationZipFilePath){using FileStream zipToOpen = new FileStream(destinationZipFilePath, FileMode.Create);using ZipArchive archive = new ZipArchive(zipToOpen, ZipArchiveMode.Create);string currentPath = sourceFolderPath;AddFiles(archive, "", currentPath);}private static void AddFiles(ZipArchive archive, string currentPath, string sourceFolderPath){var files = Directory.GetFiles(sourceFolderPath);foreach (string file in files){// 获取文件的相对路径  string filePath = Path.GetFullPath(file);string relativePath = filePath.Substring(sourceFolderPath.Length).TrimStart(Path.DirectorySeparatorChar);// 将文件添加到ZIP存档  var readOnlyEntry = archive.CreateEntry(Path.Combine(currentPath, relativePath));using var fileToCompress = File.OpenRead(file);using var entryStream = readOnlyEntry.Open();fileToCompress.CopyTo(entryStream);}// 递归处理子文件夹  string[] directories = Directory.GetDirectories(sourceFolderPath);foreach (string dir in directories){string folderName = Path.GetFileName(dir);AddFiles(archive, Path.Combine(currentPath, folderName), dir);}}
}

调用时候最好用 DoCompressDirectoryInfo方法

http://www.wangmingla.cn/news/95942.html

相关文章:

  • 贵阳网站建设黔搜搭建网站
  • 常德政府采购网官网宁波seo推广
  • 开发网站建设优化师是一份怎样的工作
  • 求职网站开发开题报告惠州seo计费管理
  • 刚做的网站怎么才能搜索到网站建设深圳公司
  • 网站建设公司 南宁温州免费建站模板
  • 网站建设大作业选题热搜在哪里可以看
  • 网页模板网站cms网络广告推广平台
  • 做旅游宣传图的网站有哪些如何制作网址链接
  • 微信创建网站应用程序惠州seo整站优化
  • 该怎么给做网站的提页面需求上海十大公关公司排名
  • 建站工具指北成都seo培训班
  • 企业网站建设基本要素网站后台管理系统
  • wordpress更换帝国志鸿优化网下载
  • digging into wordpress上海优化seo排名
  • 平度做网站推广苏州手机关键词优化
  • 九江做网站的公司seo研究中心
  • 三明网站建设客户资源买卖平台
  • 网站做小学一年二班作业怎么做网页设计模板html代码
  • 公司做网站效果怎么样网址怎么弄
  • 网站建设团购矿产网站建设价格
  • 看设计案例的有哪些网站360广告推广平台
  • wordpress所有图片都裁剪seo优化工具哪个好
  • 大气医院网站源码企拓客软件多少钱
  • 怎么查公司网站可信度b2b免费推广网站
  • 汽车之家网页版地址seo关键词优化报价价格
  • 专做毕业设计的网站怎么根据视频链接找到网址
  • 西安到北京防疫政策北京seoqq群
  • 杭州网站建设哪家强seo主要做什么
  • wordpress面邮箱注册seo发包排名软件