このスレッドで見つけたものを試してみましたが、思い通りに機能しませんでした... 画像があるかどうかという名前のフォルダーがありphotos
ますmay
。はpicture's name
、matriculation
クライアントのです。matriculation
asを渡し、渡したの名前を持つ があるかどうかを確認する必要がありparameter
ますpicture
matriculation
parameter
私はこれを試しました:
public void VerifyPhoto(string matriculation)
{
string path = Txt_PhotosPath.Text;
var file = Directory.GetFiles(path, matriculation + ".jpg");
}
写真が見つかったかどうかを確認するにはどうすればよいですか? これを比較してみたのですfile != null
が、型ではうまくいきませんvar
。ヒントはありますか?debuging
あるので写真を見つけたのを見ましたが、それString[1]
はわかりませんcheck
...
---更新--- path
:C:"\Users\admin\Desktop\photos" matriculation
:"607659.jpg" その名前のファイルがありますが、false
何が問題なのですか?
string path = Txt_PhotosPath.Text;
string filename = string.Format("{0}.jpg", matriculation);
if (Directory.Exists(path))
{
if (File.Exists(Path.Combine(path, filename)))
{
return true;
}
else
return false;
}
else
return false;