Created
June 21, 2020 13:16
-
-
Save akilab/d66bf9b56b9d0e1146b8e3bc16e587b3 to your computer and use it in GitHub Desktop.
ZIPファイル内のテキストを読み込む
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.IO; | |
| using System.IO.Compression; | |
| namespace ZipReader | |
| { | |
| internal class Program | |
| { | |
| public static void Main(string[] args) | |
| { | |
| Console.WriteLine("Hello"); | |
| string zipPath = "xxxxx.zip"; | |
| using (ZipArchive e = ZipFile.Open(zipPath, ZipArchiveMode.Read)) | |
| { | |
| foreach (ZipArchiveEntry entry in e.Entries) | |
| { | |
| if (entry.Name.Contains(".csv")) | |
| { | |
| Console.WriteLine(entry.Name); | |
| using (var sr = new StreamReader(entry.Open())) | |
| { | |
| int num = 1; | |
| string line; | |
| sr.ReadLine();//1行目スキップ | |
| while ((line = sr.ReadLine()) != null) | |
| { | |
| Console.WriteLine("{0}:{1}", num, line); | |
| num++; | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Zipファイル内のテキストを検索する
ZIP内部が、フォルダで階層構造になっていても関係なく
e.Entriesでファイルを順次処理できる。
ZIP構造あまりわかっていない。