private async void Form1_Load(object sender, EventArgs e)
{
// アプリケーションのベースディレクトリを取得する改良された方法
string directoryPath;
// Assembly.Location が空の場合は AppContext.BaseDirectory を使用
string assemblyPath = Assembly.GetExecutingAssembly().Location;
if (string.IsNullOrEmpty(assemblyPath))
{
// 単一ファイル配置の場合はこちらが実行される
directoryPath = AppContext.BaseDirectory;
}
else
{
// 通常配置の場合はこちらが実行される
directoryPath = Path.GetDirectoryName(assemblyPath);
}
....
}