私のベースディレクトリにはイメージ用のフォルダがあります。このフォルダには、イメージが1つしかありません。イメージの名前を取得してImage Sourceにロードします。このコードでは、エラーが発生します:wpfのベースディレクトリ(アプリケーションディレクトリ)内でイメージ名を取得する方法C#
Could not find file'C:\Users\Santhosh\Documents\Visual Studio 2012\imagetest\imagetest\bin\Debug\ImageFolder\System.Linq.Enumerable+WhereSelectArrayIterator`2[System.String,System.String].jpg'
ベースディレクトリからイメージ名を取得するにはどうすればよいですか?
これは私のコード
string ImageFiles=Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory+"\\ImageFolder\\",".jpg").Select(System.IO.Path.GetFileName).ToString();
image1.source== new BitmapImage(new Uri(AppDomain.CurrentDomain.BaseDirectory + "\\ImageFolder\\"+ImageFiles+".jpg"));
あなたはデバッグフォルダにいますか?このディレクトリにはC:¥Users¥Santhosh¥Documents¥Visual Studio 2012¥imagetest¥imagetest¥bin¥Debug¥ImageFolder? – doremifasolasido
そして、.ToString onを選択しないでください。 – doremifasolasido
はいデバッグフォルダ – santhosh