-
C#樹林
[C#] Controlling Log Levels with appsettings.json
In .NET Core applications, you can adjust which log levels are output by modifying the configuration file (appsettings.json) without changing your source code. This makes it easy to switch between environments, such as showing only error... -
C#樹林
【C#】appsettings.jsonでログの出力レベルを制御する
.NET (Core) アプリケーションでは、ソースコードを修正することなく、設定ファイル(appsettings.json)を書き換えるだけで「どのレベルのログを出力するか」を調整できます。 本番環境ではエラーのみを表示し、開発環境ではデバッグ情報をすべて表示する... -
C#樹林
[C#] Logging with ILogger in .NET Generic Host
For console applications in .NET Core and later (including .NET 5, 6, and 8), the standard method for professional logging is combining Microsoft.Extensions.Logging and Microsoft.Extensions.Hosting. Unlike System.Console.WriteLine, this ... -
C#樹林
【C#】ILoggerを使ってログを出力する (.NET Generic Host)
.NET Core 以降(.NET 5/6/8含む)のコンソールアプリケーションで、本格的なログ出力を行うには Microsoft.Extensions.Logging と Microsoft.Extensions.Hosting を組み合わせるのが標準的な手法です。 System.Console.WriteLine とは異なり、ログレベル... -
Python樹林
Setting Basic Graph Elements with Matplotlib Axes Objects
This guide explains how to set basic elements like titles, axis labels, display ranges (limits), grid lines, and legends using the Matplotlib object-oriented interface (Axes object). These elements are essential for making your data visu... -
Python樹林
【Python】Matplotlibでグラフのタイトル・軸ラベル・範囲・凡例を設定する基本パターンの解説
Matplotlibのオブジェクト指向インターフェース(Axesオブジェクト)を使用して、グラフのタイトル、軸ラベル、表示範囲(リミット)、グリッド線、凡例といった基本的な構成要素を設定する方法を解説します。 データの可視化において、これらの情報はグラ... -
C#樹林
[C#] Extracting a Specific File from a ZIP Archive (ExtractToFile)
Sometimes, instead of extracting every file in a ZIP archive, you may want to search for and extract only one specific file. By using the ExtractToFile method of the ZipArchiveEntry class, you can write the retrieved entry (file informat... -
C#樹林
【C#】Zipアーカイブから特定のファイルだけを解凍・抽出する (ExtractToFile)
Zipファイルをすべて解凍するのではなく、中身を検索して「特定のファイル1つだけ」を取り出したい場合があります。 ZipArchiveEntry クラスの ExtractToFile メソッドを使用すると、取得したエントリ(ファイル情報)を直接指定したパスにファイルとして... -
C#樹林
[C#] Extracting (Unzipping) a ZIP File (ZipFile.ExtractToDirectory)
To extract all files within a ZIP archive to a specific folder, use the ExtractToDirectory method of the System.IO.Compression.ZipFile class. This method is very convenient because it automatically creates the destination folder if it do... -
C#樹林
【C#】Zipファイルを解凍(展開)する (ZipFile.ExtractToDirectory)
Zipアーカイブ内のすべてのファイルを、指定したフォルダーにまとめて解凍するには、System.IO.Compression.ZipFile クラスの ExtractToDirectory メソッドを使用します。 このメソッドは、解凍先のフォルダーが存在しない場合に自動的に作成してくれるた... -
C#樹林
[C#] Getting a List of Files in a ZIP Without Extracting Them (ZipArchive.Entries)
It is common to want to check the contents of a ZIP file or verify if a specific file exists before extracting everything. By using the System.IO.Compression.ZipFile.OpenRead method, you can quickly access the information (entries) withi... -
C#樹林
【C#】Zipファイルを解凍せずに中身のファイル一覧を取得する (ZipArchive.Entries)
Zipファイルをすべて解凍する前に、「中にどんなファイルが入っているか確認したい」「特定のファイルだけが存在するかチェックしたい」という場面はよくあります。 System.IO.Compression.ZipFile.OpenRead メソッドを使用すると、ファイルを展開すること... -
C#樹林
[C#] Deleting a Specific File in a ZIP File (ZipArchiveEntry.Delete)
Sometimes, after creating a ZIP archive, you may want to remove only specific files. For example, you might have included log files by mistake or want to exclude old configuration files from the archive. To perform this operation, you mu... -
C#樹林
【C#】Zipファイル内の特定のファイルを削除する (ZipArchiveEntry.Delete)
Zipアーカイブ(圧縮ファイル)を作成した後、特定のファイルだけを取り除きたい場合があります。 例えば、ログファイルを含めて圧縮してしまったが後から削除したい場合や、古い設定ファイルをアーカイブから除外したい場合などです。 この操作を行うには... -
C#樹林
[C#] Adding and Appending Files to an Existing ZIP File (ZipArchiveMode.Update)
To add new files to a ZIP file that has already been created, or to update existing files, open the file using the ZipFile.Open method with ZipArchiveMode.Update. Once the ZipArchive object is opened in this mode, you can easily add file... -
C#樹林
【C#】既存のZipファイルに新しいファイルを追加・追記する (ZipArchiveMode.Update)
既に作成済みのZIPファイルに対して、後から別のファイルを追加したり、既存のファイルを更新したりするには、ZipFile.Open メソッドで ZipArchiveMode.Update モードを指定して開きます。 このモードで開かれた ZipArchive オブジェクトに対して CreateEn... -
C#樹林
[C#] Compressing a Directory to a ZIP File (ZipFile.CreateFromDirectory)
To combine the contents of a specific directory into a single ZIP file (archive), it is standard to use the CreateFromDirectory method of the System.IO.Compression.ZipFile class. Using this method allows you to complete the compression p... -
C#樹林
【C#】ディレクトリ(フォルダ)をZIPファイルに圧縮する (ZipFile.CreateFromDirectory)
指定したディレクトリの中身をまとめて1つのZIPファイル(アーカイブ)にするには、System.IO.Compression.ZipFile クラスの CreateFromDirectory メソッドを使用するのが標準的です。 このメソッドを使うと、面倒なストリーム操作を記述することなく、1行... -
C#樹林
[C#] Handling Strings as a Stream (MemoryStream)
There are situations where you want to test a method that accepts a file, but creating a physical file is a hassle. You might also want to process string data received from a network in the same way you would handle a file. In such cases... -
C#樹林
【C#】文字列をStream(ストリーム)として扱う (MemoryStream)
「ファイルを受け取るメソッドをテストしたいが、わざわざ物理ファイルを作るのは面倒」という場面や、「ネットワークから取得した想定の文字列データを、ファイルと同じように処理したい」というケースがあります。 そのような場合、文字列(string)をバ... -
C#樹林
[C#] Writing Byte Array Data to a File (FileStream.Write)
When saving byte[] (byte array) data—such as image data, communication packets, or custom binary formats—as a file, using the FileStream class allows for flexible writing. While there is a simple method called File.WriteAllBytes to write... -
C#樹林
【C#】バイト配列のデータをファイルに書き込む (FileStream.Write)
画像データや通信パケット、あるいは独自のバイナリ形式など、byte[](バイト配列)のデータをファイルとして保存する場合、FileStream クラスを使用することで柔軟な書き込み処理が可能になります。 単にすべてのバイトを書き込むだけであれば File.Write... -
Python樹林
Understanding Matplotlib’s Structure: Flexible Visualization with Figure and Axes
When using Matplotlib for data visualization, the first step to creating complex layouts is understanding the relationship between the "Figure" and "Axes." Relationship Between Figure and Axes Matplotlib graphs are managed in a hierarchi... -
Python樹林
【Python】Matplotlibの描画構造を理解する:FigureとAxesによる柔軟なグラフ作成
Matplotlibを利用してデータ可視化を行う際、描画の土台となる「Figure」と、個別のグラフ領域である「Axes」の関係を正しく把握することは、複雑なレイアウトを実現するための第一歩です。 描画の基本構造:FigureとAxesの関係 Matplotlibのグラフは、階... -
Python樹林
[Python] Differences Between Two Matplotlib Coding Styles: Pyplot and Object-Oriented
Two Main Styles in Matplotlib There are two main ways to create graphs using Matplotlib: the "Pyplot Style (MATLAB Style)" and the "Object-Oriented Style." The Pyplot style is simple and suitable for small scripts or quick data checks. I... -
Python樹林
【Python】Matplotlibの2つの記述法:Pyplot形式とオブジェクト指向形式の違い
Matplotlibにおける2つの主要なスタイル Matplotlibを用いたグラフ作成には、大きく分けて「Pyplot形式(MATLABスタイル)」と「オブジェクト指向形式」の2種類の記述方法があります。 Pyplot形式は記述が簡潔で、小規模なスクリプトやクイックなデータ確... -
C#樹林
[C#] Reading Binary Files in Chunks Using FileStream and yield return
When handling binary data like images or executable files (DLL/EXE), reading everything into memory at once with File.ReadAllBytes can lead to an OutOfMemoryException if the file is very large. By combining FileStream and yield return, y... -
C#樹林
【C#】バイナリファイルを少しずつ読み込む (FileStreamとyield return)
画像ファイルや実行ファイル(DLL/EXE)などのバイナリデータを扱う際、File.ReadAllBytes で一括でメモリに読み込むと、巨大なファイルを扱った際にメモリ不足(OutOfMemory)になるリスクがあります。 FileStream と yield return を組み合わせて、決ま... -
C#樹林
【C#】Shift-JISなど特定の文字コードでファイルを読み書きする
.NET Core (.NET 5以降含む) では、デフォルトで Shift-JIS などのレガシーな文字コードがサポートされていません。 そのため、Shift-JIS を扱うには、追加のエンコーディングプロバイダーを登録(RegisterProvider)する手順が必要です。 ここでは、Shift... -
C#樹林
[C#] How to Append Line Data to a Text File (File.AppendAllLines)
To append new line data to the end of an existing text file, use the System.IO.File.AppendAllLines method. This method automatically creates a new file if the specified file does not exist. If the file already exists, it writes the data ...