以下の内容はhttps://blog.systemjp.net/entry/2025/03/26/230117より取得しました。


C# 通常ビルドと単一ファイル配置するときでは アプリケーションのベースディレクトリを取得する方法が違う

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);
    }
 
....
} 
 



以上の内容はhttps://blog.systemjp.net/entry/2025/03/26/230117より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14