解压
System.IO.Compression.ZipFile
ZipFile.OpenRead 读取压缩包
ZipFile.OpenRead.Entries 读取压缩包里面所有的文件夹与文件
1 //获取地址 2 var Url = "Https://" + data["Url"]?.ToString(); 3 //下载地址对应的压缩包 4 HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url); 5 HttpWebResponse response =(HttpWebResponse)request.GetResponse(); 6 Stream st =response.GetResponseStream(); 7 //读取压缩包里面的文件 8 ZipInputStream s =new ZipInputStream(st); 9 ZipEntry entry; 10 while ((entry = s.GetNextEntry()) != null) 11 { 12 if (entry.Name.Contains(".txt")) 13 { 14 //读取文件里面的信息 15 using (StreamReader sr = new StreamReader(s)) 16 { 17 string line = string.Empty; 18 while ((line = sr.ReadLine()) != null) 19 { 20 NewClassInChatRecord newClassIn = JsonConvert.DeserializeObject<NewClassInChatRecord>(line); 21 list.Add(newClassIn); 22 } 23 } 24 } 25 }View Code
标签:读取,Url,ZipFile,外脑,entry,net,line,压缩包 From: https://www.cnblogs.com/huodetiantang/p/17315987.html