このスレッドで見つけたものを試してみましたが、思い通りに機能しませんでした... 画像があるかどうかという名前のフォルダーがありphotosますmay。はpicture's name、matriculationクライアントのです。matriculationasを渡し、渡したの名前を持つ があるかどうかを確認する必要がありparameterますpicturematriculationparameter
私はこれを試しました:
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;