"아이콘"폴더가 있습니다. imageList
에 아이콘을 추가하려면 동일한 항목에 액세스해야합니다. 상대 경로가있는 app.config 파일을 사용하고 있습니다.App.config 상대 경로
<add key="doc" value="..\Icons\_Microsoft Office Excel 97-2003 Worksheet.ico" />
내가 imgList
에 추가하는 코드 아래 사용하고는, 그러나 그것은 System.IO.FileNotFoundException
를 던졌습니다 :
smallImageList.Images.Add(Image.FromFile(ConfigurationSettings.AppSettings["doc"]));
무슨 문제 있습니까? 현재 실행중인 경로를 추가
고마워요. 그게 .. .. Path.GetFullPath (ConfigurationSettings.AppSettings [ "doc"]); 이 작품은 .. 내가 알고 싶었 메신저 무엇인가 잘못이다 smallImageList.Images.Add (Image.FromFile (ConfigurationSettings.AppSettings [ "doc"]))); – Anees
smallImageList.Images.Add (Image.FromFile (Path.GetFullPath (ConfigurationSettings.AppSettings [ "doc"])))); – Anees
답변으로 표시되어야합니다. 문제는'Image.FromFile'은 상대 경로가 아닌 절대 경로를 기대한다는 것입니다. – Oliver