mori– Author –
-
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 ... -
C#樹林
【C#】テキストファイルに行データを追記する (File.AppendAllLines)
既存のテキストファイルの末尾に、新しい行データを追加したい場合は System.IO.File.AppendAllLines メソッドを使用します。 このメソッドは、指定したファイルが存在しない場合は自動的に新規作成し、存在する場合は元のデータを消さずに、その続きから... -
C#樹林
[C#] Writing Array Data to a Text File (File.WriteAllLines)
To save a "string array" or "list" directly to a file, using the WriteAllLines method in the System.IO.File class is the most efficient way. By using this method, you do not need to write a loop with StreamWriter; you can complete the da... -
C#樹林
【C#】配列のデータをテキストファイルとして書き出す (File.WriteAllLines)
プログラム内で扱っている「文字列の配列」や「リスト」を、そのままファイルに保存したい場合、C# の System.IO.File クラスにある WriteAllLines メソッドを使うのが最もスマートです。 このメソッドを使えば、StreamWriter を使ってループ処理を書く必... -
C#樹林
[C#] Reading a Text File Line by Line (File.ReadLines)
There are several ways to read the contents of a text file. The File.ReadLines method is unique because it uses "lazy execution," which means it reads data bit by bit as needed. This makes it extremely memory-efficient when handling mass... -
C#樹林
【C#】テキストファイルを1行ずつ読み込む (File.ReadLines)
テキストファイルの中身を読む方法はいくつかありますが、File.ReadLines メソッドは**「必要な分だけ少しずつ読み込む(遅延実行)」**という特性を持っており、ログファイルのような巨大なファイルを扱う際や、先頭の数行だけを確認したい場合に非常にメ... -
C#樹林
[C#] How to Get Paths of Special Folders like Documents and Desktop (Environment.GetFolderPath)
It is not recommended to hardcode paths like C:\Users\Name\... because they vary by OS and user. Instead, use the Environment.GetFolderPath method and the Environment.SpecialFolder enum. This allows you to dynamically retrieve the correc... -
C#樹林
【C#】マイドキュメントやデスクトップなどの特殊フォルダのパスを取得する (Environment.GetFolderPath)
OSやユーザーごとに異なる「マイドキュメント」「デスクトップ」「AppData」などのパスをハードコーディング(C:\Users\Name\... と直接書くこと)するのは推奨されません。 代わりに Environment.GetFolderPath メソッドと Environment.SpecialFolder 列... -
C#樹林
[C#] Creating Temporary Files and Locating the Temp Folder (Path.GetTempFileName)
When you want to save temporary work data (such as cache, logs, or intermediate files during a download) while an application is running, it is common to use the system's standard "Temp" folder. By using the Path.GetTempFileName method, ... -
C#樹林
【C#】一時ファイルを作成する・一時フォルダの場所を取得する (Path.GetTempFileName)
アプリケーションの処理中に、作業用の一時データ(キャッシュやログ、ダウンロード中の中間ファイルなど)を保存したい場合、システム標準の「一時フォルダ(Temp)」を利用するのが一般的です。 Path.GetTempFileName メソッドを使用すると、一時フォル... -
C#樹林
[C#] How to Get and Change the Current Working Directory
To get the "Current Directory," which is the base directory where the program is currently running, use the Directory.GetCurrentDirectory method. This directory serves as the starting point when reading or writing files using relative pa... -
C#樹林
【C#】現在の作業ディレクトリ(カレントディレクトリ)を取得・変更する
プログラムが現在実行の基準としている「作業ディレクトリ(Current Directory)」を取得するには、Directory.GetCurrentDirectory メソッドを使用します。 相対パス(例:./data.txt)でファイルを読み書きする際、このカレントディレクトリが起点となり... -
C#樹林
[C#] How to Get a List of Subdirectories in a Directory (Directory.GetDirectories)
To find out what subfolders exist inside a specific folder, use the Directory.GetDirectories method. Similar to file searches, you can filter results using wildcards and choose whether to search through all levels of subfolders. Table of... -
C#樹林
【C#】指定したディレクトリにあるサブディレクトリ(フォルダ)一覧を取得する (Directory.GetDirectories)
指定したフォルダの中にどのようなサブフォルダが存在するかを調べるには、Directory.GetDirectories メソッドを使用します。 ファイル検索と同様に、ワイルドカードによるフィルタリングや、サブフォルダのさらに奥階層まで検索するかどうかを指定できま... -
C#樹林
[C#] Searching and Getting a List of Files in a Directory (Directory.GetFiles)
To get a list of file names in a specific folder, use the Directory.GetFiles method. This method allows you to filter files using "wildcards" for specific extensions or naming patterns. You can also search through subfolders by specifyin... -
C#樹林
【C#】指定したディレクトリにあるファイル一覧を検索・取得する (Directory.GetFiles)
特定のフォルダ内にあるファイル名の一覧を取得するには、Directory.GetFiles メソッドを使用します。 このメソッドでは、「ワイルドカード」を使用して特定の拡張子や名前のパターンを持つファイルだけをフィルタリングしたり、検索オプションを指定して... -
C#樹林
[C#] Creating, Deleting, and Moving Directories (Folders)
In addition to files, you can manage directories (folders) using the static methods of the System.IO.Directory class. In particular, the CreateDirectory method is very convenient because it automatically creates any missing parent folder...