1

私は画像に問題があり、gridBg.png というアプリケーションの背景を作成し、次のように読みました。

        string currentDir = Directory.GetCurrentDirectory();

        if (File.Exists((currentDir + @"/Images/gridBg.png")))
        {
            bgAnimated.StopAnimation();
            bgAnimated.GifSource = currentDir + @"/Images/gridBg.png";
            bgAnimated.NormalLoopFrameCount = 20;
            bgAnimated.SpecialLoopFrameCount = 20;
            bgAnimated.TotalLoopFrameCount = 40;
            bgAnimated.NormalLoopRepeatCount = 1;
            bgAnimated.SpecialLoopRepeatCount = 1;
            bgAnimated.StartAnimation();
        }

デバッグモードでは、すべて正常に動作します。セットアップ プロジェクトにイメージを追加し、それにイメージ パスを指定しました。アプリケーションをインストールして試してみると、正常に動作しますが、問題は、友人の何人かが画像を表示しないことですが、画像は適切な場所 (Images フォルダー) にあります。誰かが提案していますか?

解決済み: string currentDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

4

1 に答える 1

3

これが起こる可能性があると私が考える唯一の方法は、Working Directoryあなたの友人がインストールディレクトリに設定されていないことです. これにより、currentDirが間違っている可能性があります。

MSDNのドキュメントに従ってGetCurrentDirectoryこれを行います:

アプリケーションの現在の作業ディレクトリを取得します

于 2013-07-10T18:38:36.530 に答える