// The following line works.
imagebox.Image = Image.FromFile("C:/Users/Admin/Desktop/apps/pic1.png");
// The following line does not work.
imagebox.Image = Image.FromFile(imgPath);
// the test Text Box displays "C:/Users/Admin/Desktop/apps/pic1.png", exactly like in the first line
test.Text = imgPath;
ピクチャボックスの画像を変更するはずのボタンをクリックすると、基本的にパスに不正な文字が含まれているというエラーが発生し、ArgumentException は処理されませんでした
初めてそれをしなかったことを申し訳ありません。
k そのため、実際のファイル名がテキスト ボックスに入力されています。次に、そのテキストを文字列に変換し、それを begging と end に追加して、完全なファイル パスを作成します。
string path = "\"C:/Users/Admin/Desktop/apps/";
string ext1 = ".png\"";
ID = idBox.Text;
imgPath = path + ID + ext1;
try
{
imagebox.Image = Image.FromFile(imgPath);
}
catch (System.IO.FileNotFoundException)
{
MessageBox.Show("Invalid Student or Faculty ID.");
}