此方法适用于C盘windows文件夹中有WinRAR.exe文件 if (fileExt.ToUpper() == ".RAR") { string zpath = Server.MapPath("~/SendFileZIP/"); //不存在文件夹时创建文件夹 if (!Directory.Exists(zpath)) { Directory.CreateDirectory(zpath); } //导入rar 压缩文件时,清空SendFileZIP文件夹里面所有的文件 DirectoryInfo clera = new DirectoryInfo(zpath); deletefileOrDic(clera); //解压 上传的rar文件 int count = RARToFileEmail(zpath, filePath); //判断解压是否成功 解压出来的文件数量是否大于 if (count > 0) { string[] strFiles = Directory.GetFiles(zpath); string strfiel = ""; foreach (string item in strFiles) { DirectoryInfo dirtory = new DirectoryInfo(item); //获取不是文件夹时 if (!dirtory.Exists) { strfiel = strfiel + item.ToString(); break; } } string zname = Path.GetFileName(strfiel).ToString();//获取 解压后的文件的名称 //解压后文件的名称 string zFilePath = zpath + zname; } }
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步