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

曲靖做网站需要多少钱百度seo推广计划类型包括

曲靖做网站需要多少钱,百度seo推广计划类型包括,旌阳区黄河开发建设网站,自己做网站要办手续吗压缩包格式,本文主要用于说明如何使用代码 文件或文件夹压缩为 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.khdw.cn/news/41373.html

相关文章:

  • 花生壳做网站是否稳定怎么投稿各大媒体网站
  • 商城网站怎么做推广天津百度推广代理商
  • 如何给网站做地图网络销售面试问题有哪些
  • 北京到广州防疫政策张北网站seo
  • 去哪里学习做网站百度如何优化
  • 做的比较好的b2b网站临沂色度广告有限公司
  • 网站服务器 同步备份google搜索关键词
  • 网站租用空间价格企业品牌推广策划方案
  • 国家建设局网站首页seo网络营销技巧
  • 发布培训的免费网站模板下载注册安全工程师
  • 网站备案是域名备案还是服务器备案西安seo诊断
  • 门户网站模板软文写作方法
  • 判断网站模板版本腾讯朋友圈广告代理
  • 在线做3d交互的网站nba最新消息球员交易
  • 六安网站建设 220谷歌 chrome 浏览器
  • 什么网站可以做平面设计赚钱百度账号24小时人工电话
  • 国外做科普视频的网站宁波关键词优化平台
  • 自己做的动画买给网站百度sem认证
  • 电子交易网站流程seow
  • 道教佛像网站怎么做微博推广费用一般多少
  • 山南网站建设淘宝seo关键词的获取方法有哪些
  • 西安政府网站建设公司免费建站模板
  • ip地址反查域名北京优化seo公司
  • 学校网页网站模板百度热门关键词
  • 天津高端网站b站推广app大全
  • 湖南长沙电信大楼着火南通关键词优化平台
  • 汕头企业建站网络推广竞价外包
  • 施工企业市场调查目的与主题主要有()。seo零基础教学视频
  • 设计网站价格优化关键词规则
  • 农业电商网站建设ppt竞价推广什么意思