我尝试了我在这个线程上找到的内容,但没有完全按照我想要的方式工作......我有一个名为photos它的文件夹是否may有图片。picture's name是matriculation客户的。我需要通过matriculationasparameter并检查是否有一个我通过 aspicture的名称matriculationparameter
我试过这个:
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;