zoukankan      html  css  js  c++  java
  • C# 上传RAR文件 解压 获取解压后的文件名称

    此方法适用于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;

    }

    }

  • 相关阅读:
    10.17 作业
    10.12 classmethod,staticmethod,反射,魔法方法
    10.11 组合,封装,多态
    10.11 作业
    day20 作业
    10.10 类的继承,继承关系,派生,新式类,经典类
    10.9 类,对象,查找顺序,对象绑定方法
    day 55小结
    day 54小结
    day 53小结
  • 原文地址:https://www.cnblogs.com/dachuang/p/3696359.html
Copyright © 2011-2022 走看看