Пример #1
0
 private void unZip(string path)
 {
     //在线浏览
     string root = Server.MapPath("~/");
     if (!Directory.Exists(root + @"/unCompressedFile"))
     {
         Directory.CreateDirectory(root + @"/unCompressedFile");
     }
     string filePath = root + @"/" + path; //文件路径
     string fileName = Path.GetFileNameWithoutExtension(filePath);//获取文件名
     string creaPath = root + @"/unCompressedFile" + "\\" + fileName;
     if (!Directory.Exists(creaPath))
     {
         DirectoryInfo dir =  Directory.CreateDirectory(creaPath);
         if (filePath.ToLower().EndsWith(".rar") || filePath.ToLower().EndsWith(".zip"))
         {
             string[] FileProperties = new string[2];
             FileProperties[0] = filePath;//待解压的文件
             FileProperties[1] = Server.MapPath("~/") + @"/unCompressedFile" + @"/" + fileName;//解压后放置的目标目录
             unCompressRAR unRar = new unCompressRAR();
             unRar.unRAR(FileProperties[0], FileProperties[1]); //解压文件到指定目录
         }
         else
         {
             FileInfo fi = new FileInfo(filePath);
             fi.CopyTo(dir.FullName + @"/" + fileName.Substring(fileName.LastIndexOf('_')+1) + Path.GetExtension(filePath));
         }
     }
 }
Пример #2
0
 protected void lbtScan_Click(object sender, EventArgs e)
 {
     //在线浏览
     string root = Server.MapPath("~/");
     if (!Directory.Exists(root + @"/unCompressedFile"))
     {
         Directory.CreateDirectory(root + @"/unCompressedFile");
     }
     string filePath = root + @"/" + _siteFileInfo.StrUrl; //文件路径
     string fileName = Path.GetFileNameWithoutExtension(filePath);//获取文件名
     string creaPath = root + @"/unCompressedFile" + "\\" + fileName;
     string title = _siteFileInfo.StrDescription;
     if (!Directory.Exists(creaPath))
     {
         DirectoryInfo dir =  Directory.CreateDirectory(creaPath);
         if (filePath.ToLower().EndsWith(".rar") || filePath.ToLower().EndsWith(".zip"))
         {
             string[] FileProperties = new string[2];
             FileProperties[0] = filePath;//待解压的文件
             FileProperties[1] = Server.MapPath("~/") + @"/unCompressedFile" + @"/" + fileName;//解压后放置的目标目录
             unCompressRAR unRar = new unCompressRAR();
             unRar.unRAR(FileProperties[0], FileProperties[1]); //解压文件到指定目录
         }
         else
         {
             FileInfo fi = new FileInfo(filePath);
             fi.CopyTo(dir.FullName + @"/" + fileName.Substring(fileName.LastIndexOf('_')+1) + Path.GetExtension(filePath));
         }
     }
     Response.Redirect("~/scanFile.aspx?title=" + title + "&fileName=" + fileName + "&type=" + HiddenFieldType.Value + "&caseId=" + this._siteFileInfo.ICaseId);
 }