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

曲靖做网站需要多少钱泉州百度网站推广

曲靖做网站需要多少钱,泉州百度网站推广,怎样做公司网站banner,电商平台商户压缩包格式,本文主要用于说明如何使用代码 文件或文件夹压缩为 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.zhongyajixie.com/news/60716.html

相关文章:

  • 动漫设计与制作难吗玉溪seo
  • 做网站建设公司赚钱吗免费建网站软件哪个好
  • 怎么自己弄网站企业网站排名优化方案
  • 济南公司建站模板国内搜索引擎排行榜
  • 临沂网站建设设计启动互联全网营销推广
  • 网站建设易尔通网络营销案例ppt课件
  • jsp网站设计杭州专业seo服务公司
  • 广州网站建设信科便宜淘宝指数在哪里查询
  • wordpress广告布局海曙seo关键词优化方案
  • 一个完整的企业网站营销网站类型
  • 网站seo建设方案百度应用商店官网
  • 眉山 网站开发crm系统
  • 做淘宝要网站电池优化大师下载
  • 做网站广告公司惠州seo关键词推广
  • php动态网站制作流程图百度推广营销
  • wordpress 清单 主题企业站seo报价
  • 合肥网站建设服务公司seo优化培训公司
  • 广州网站建设 中网科技榆林百度seo
  • 永康医院网站建设电脑优化是什么意思
  • 深圳电子商城网站建设湘潭seo快速排名
  • html5响应式网站模板百度广告联盟app
  • 哪些网站是做外贸生意的游戏推广员好做吗
  • 网站中文域名续费是什么情况google搜索引擎入口2022
  • 深圳外贸网站建设服务哪家好百度推广优化师培训
  • 如何编写一个网站此网站三天换一次域名
  • 江苏省建设厅新疆办网站首页黑马培训价目表
  • 网站页面统计代码是什么爱站网seo综合查询工具
  • 网站脑图用什么做开发网站
  • 安庆做网站优化师和运营区别
  • 微站营销app