ケース:ログインしているベンダーごとにカスタマイズされた画像を表示する必要があるデスクトップ アプリケーションがあります。したがって、App.config
では、イメージ ファイルがキーとして追加されます。
<add key="Logo" value="companylogo_2.jpg"/>
コントロールでそれを消費する方法はToolstripLabel
?
注: App.config ファイルでは、値にイメージのフル パスは含まれず、イメージの名前のみが含まれます。
トライアル:
1.
smallImageList.Images.Add(Image.FromFile(ConfigurationSettings.AppSettings["Logo"]));
2.
string CurrDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
smallImageList.Images.Add(Image.FromFile(Path.Combine(CurrDirectory,ConfigurationSettings.AppSettings["Logo"])));