--- lang: ja-jp breaks: true --- # C# 7z SevenZipSharp を使用して lzh を解凍する 2021-06-04 ##### 7z 本体のダウンロード > 7z ダウンロード > https://sevenzip.osdn.jp/download.html ##### CODE PROJECT の投稿 > C# (.NET) Interface for 7-Zip Archive DLLs > https://www.codeproject.com/Articles/27148/C-NET-Interface-for-7-Zip-Archive-DLLs ##### CodePlex の アーカイブ > sevenzipsharp > https://archive.codeplex.com/?p=sevenzipsharp ##### 既にArchivedとなっているfork > tomap/SevenZipSharp > https://github.com/tomap/SevenZipSharp ##### .Net Core に対応したfork > squid-box/SevenZipSharp > https://github.com/squid-box/SevenZipSharp ## NuGet ![](https://i.imgur.com/uaNPrBA.png) ## 「squid-box/SevenZipSharp」を使用したサンプルコード ```csharp= using System.IO; using SevenZip; ・・・ static void Main(string[] args) { FileInfo lzhFile = new FileInfo(@"C:\temp\XXXX.lzh"); SevenZipBase.SetLibraryPath("7z.dll"); DirectoryInfo dirExtra = new DirectoryInfo( Path.Combine( lzhFile.Directory.FullName, Path.GetFileNameWithoutExtension(lzhFile.Name) ) ); if (dirExtra.Exists == false) { dirExtra.Create(); } using (var extractor = new SevenZipExtractor(lzhFile.FullName)) { extractor.ExtractArchive(dirExtra.FullName); } } ・・・ ``` ###### tags: `C#` `7z` `lzh` `SevenZipSharp`