解析压缩文件zip
public static string UnZipFile(string TargetFile, string EndFile) { try { using (FileStream fs = File.Create(EndFile)) { //读取压缩文件(zip文件),准备解压缩 ZipInputStream inputstream = new ZipInputStream(File.OpenRead(TargetFile.Trim())); ZipEntry entry; //根目录下的第一个子文件夹的名称 while ((entry = inputstream.GetNextEntry()) != null) { //得到根目录下的第一级子文件夹下的子文件夹名称 string fileName = Path.GetFileName(entry.Name); if (fileName != String.Empty) { int size = 2048; byte[] data = new byte[2048]; while (true) { size = inputstream.Read(data, 0, data.Length); if (size > 0) { fs.Write(data, 0, size); } else { break; } } fs.Close(); } } inputstream.Close(); } } catch (Exception ex) { return "NG"; } return "OK"; }