mori– Author –
-
C#樹林
[C#] Building Console Applications with DI and Configuration Management Using Generic Host
Overview The "Generic Host" (Microsoft.Extensions.Hosting) is a framework that manages app startup and lifetime. While initially popularized by ASP.NET Core, it is highly effective for console applications and background services. It int... -
C#樹林
【C#】汎用ホストを使ってDIと構成管理を備えたコンソールアプリを作る
概要 ASP.NET Coreで標準化されている「汎用ホスト(Generic Host)」の仕組みをコンソールアプリケーションに適用し、依存性の注入(DI)、構成ファイル(appsettings.json)の読み込み、ロギング機能を統合管理する実装パターンです。 これにより、コン... -
C#樹林
[C#]Implementing Severity-Based Logging with TraceSwitch and the Debug Class
Overview This implementation provides a debug log output feature to monitor variable states and process execution within Visual Studio. Rather than outputting all logs indiscriminately, this system uses TraceSwitch to dynamically control... -
C#樹林
【C#】TraceSwitchとDebugクラスで重要度に応じたログ出力を実装する
概要 Visual Studioでの開発中に、変数の状態や処理の通過を確認するためのデバッグログ出力機能の実装です。 単にすべてのログを出力するのではなく、TraceSwitch を利用して「エラーのみ」「警告まで」「詳細情報すべて」といった出力レベルを動的に制御... -
C#樹林
[C#]Properly Separating Logs and Error Outputs in Console Applications
Overview In console application development, it is not recommended to mix normal execution logs and error information in the same output destination (standard output). In .NET, you can use the Console.Error property to send data to "Stan... -
C#樹林
【C#】コンソールアプリでログとエラー出力を適切に分離する実装手法
概要 コンソールアプリケーション開発において、正常な実行ログとエラー情報を同じ出力先(標準出力)に混在させることは、運用の観点から推奨されません。 .NET では Console.Error プロパティを利用することで、OSレベルで提供される「標準エラー出力(s... -
C#樹林
[C#]Retrieving Standard Output of a Started Process Programmatically
Overview This article explains how to capture the results (standard output) displayed on the console from external applications or commands (such as Git, Python, or the Command Prompt) into a C# string variable. By enabling the RedirectS... -
C#樹林
【C#】起動したプロセスの標準出力をプログラムで取得する
概要 外部アプリケーションやコマンド(Git, Python, コマンドプロンプト等)を実行し、そのコンソール画面に表示される結果(標準出力)をC#の文字列変数として取り込む方法です。 ProcessStartInfo の RedirectStandardOutput プロパティを有効にするこ... -
C#樹林
[C#] Waiting for an External Process to Complete
Overview This method stops the execution of a program until an external application or command started with Process.Start is fully finished. It is useful for synchronous processing, such as reading a file only after it has been extracted... -
Python樹林
【C#】起動した外部プロセスの終了を待機する
概要 外部アプリケーションやコマンドを Process.Start で起動した後、その処理が完全に完了するまでプログラムの実行を一時停止する方法です。 バックグラウンドではなく、同期的に処理を行いたい場合(例:ファイルの解凍が終わってから読み込む、バッチ... -
C#樹林
[C#]Starting External Processes and Commands
Overview This is how to start external applications (such as Notepad, browsers, or Command Prompt) or execute shell commands from a C# program. By using the System.Diagnostics.Process.Start method, you can run other .exe files or process... -
C#樹林
【C#】外部プロセスやコマンドを起動する
概要 C#プログラムから外部のアプリケーション(メモ帳、ブラウザ、コマンドプロンプトなど)を起動したり、シェルコマンドを実行したりする方法です。 System.Diagnostics.Process.Start メソッドを使用することで、他のexeファイルの実行や、引数を渡し... -
Linux樹林
[Linux] Convert Filename Character Encodings and Case with the convmv Command
Overview The convmv command is a tool used to convert the character encoding of "filenames" themselves, rather than the contents of the files. It is specifically designed to fix "mojibake" (garbled text) in filenames that occurs when tra... -
Linux樹林
【Linux】convmvコマンドでファイル名の文字コードや大文字・小文字を変換する
概要 ファイルの中身ではなく、「ファイル名」自体の文字コードを変換するためのコマンドです。 Windows (Shift_JIS/CP932) やMac (UTF-8 NFD) で作成されたファイルをLinux (UTF-8 NFC) に転送した際に発生する、「ファイル名の文字化け」を解消するのに... -
Linux樹林
[Linux] Create Secure Temporary Files and Directories with the mktemp Command
Overview The mktemp command is used to create unique temporary files or directories in shell scripts and other processes to avoid naming conflicts. It automatically generates filenames containing random characters, which helps avoid secu... -
Linux樹林
【Linux】mktempコマンドで安全な一時ファイル・ディレクトリを作成する
概要 シェルスクリプトなどで、他のプロセスと名前が被らない(競合しない)ユニークな一時ファイルや一時ディレクトリを作成するコマンドです。 ランダムな文字列を含むファイル名を自動生成し、セキュリティ上のリスク(予測可能なファイル名によるシン... -
Linux樹林
[Linux] Speed Up Directory Navigation with pushd, popd, and dirs
Overview When working in Linux, typing long paths with the cd command repeatedly to move between deep directory levels is inefficient. By using pushd and popd, you can remember visited directories as a "stack." This allows you to easily ... -
Linux樹林
【Linux】pushd/popd/dirsでディレクトリ移動を高速化する
概要 Linuxでの作業中、深いディレクトリ階層を行ったり来たりする際に、毎回 cd コマンドで長いパスを打ち込むのは非効率です。 pushd と popd を使うと、訪問したディレクトリを「スタック(積み上げ)」として記憶し、履歴を辿るように簡単に元の場所へ... -
Linux樹林
[Linux] Create, Extract, and Copy Archives with the cpio Command
Overview The cpio command is a tool used to create archive files or extract files from them. It works by receiving a list of file paths from standard input. While it is similar to the tar command, cpio is a filter-type command that requi... -
Linux樹林
【Linux】cpioコマンドでアーカイブを作成・展開・コピーする
概要 ファイルリストを標準入力から受け取り、アーカイブファイルを作成したり、逆にアーカイブからファイルを展開したりするためのコマンドです。 tar コマンドと似ていますが、cpio は「ファイルパスのリストをパイプで渡す必要がある」というフィルタ型... -
Linux樹林
[Linux] Extract and Manage RAR Files with the unrar Command
Overview The unrar command is used to extract files from "RAR format" archives, which offer high compression ratios. It is commonly used to handle files created in Windows or to restore large data distributed as split volumes (e.g., .par... -
Linux樹林
【Linux】unrarコマンドでRARファイルを展開・管理する
概要 高い圧縮率を誇る「RAR形式」のアーカイブファイルを展開(解凍)するためのコマンドです。 Windows環境で圧縮されたファイルの受け取りや、分割ボリューム(.part1.rar, .part2.rar...)として配布されている大容量データを結合して復元する際に使用... -
Linux樹林
[Linux] Extract LHA (.lzh) Archives with the lha Command
Overview The lha command is used to manage and extract LHA files (with the .lzh extension), a compression format that was once very popular in Japan. While it is now a legacy format, it is still necessary when handling old data assets or... -
Linux樹林
【Linux】lhaコマンドでLHA形式(.lzh)アーカイブを展開する
概要 かつて日本国内で広く普及していた圧縮形式「LHA(拡張子 .lzh)」のファイルを、Linux環境で展開(解凍)・管理するためのコマンドです。 現在ではレガシーな形式ですが、過去のデータ資産や古いソフトウェアのアーカイブを扱う際に必要となります。... -
Linux樹林
[Linux] Extract and Inspect ZIP Files with the unzip Command
Overview The unzip command is used to extract files from archives compressed in the ZIP format. Beyond just restoring files, this command allows you to list the contents without extracting or pick specific files to retrieve. It is freque... -
Linux樹林
【Linux】unzipコマンドでZIPファイルを展開・中身を確認する
概要 ZIP形式で圧縮されたアーカイブファイルを、展開(解凍)するためのコマンドです。 単にファイルを元に戻すだけでなく、展開せずに中身のファイル一覧を確認したり、特定のファイルだけを選んで取り出したりすることも可能です。Windows環境で作成さ... -
C#樹林
[C#] Accurately Measuring Elapsed Time of a Process
Overview To measure the execution speed of a program or the time taken for a specific process, we use the System.Diagnostics.Stopwatch class. This is far more accurate than calculating differences with DateTime. It also allows you to eas... -
C#樹林
【C#】処理の経過時間を正確に計測する
概要 プログラムの実行速度や、特定の処理にかかった時間を計測するために System.Diagnostics.Stopwatch クラスを使用します。 DateTime の差分を使用するよりも高精度であり、一時停止(Stop)や再開(Start)による時間の積算も簡単に行えます。 仕様(... -
C#樹林
[C#]Executing Tasks Repeatedly at Specific Intervals in C#
Overview To call a specific method repeatedly at a fixed interval, use the System.Threading.Timer class. This class uses a thread from the thread pool to execute the callback. This allows you to perform background tasks like logging or s... -
C#樹林
【C#】指定した間隔で処理を繰り返し実行する
概要 一定の時間間隔で特定のメソッドを繰り返し呼び出すには、System.Threading.Timer クラスを使用します。 これはスレッドプール上のスレッドを使用してコールバックを実行するため、メインスレッドをブロックすることなく、バックグラウンドでの定期処...