Gha*_*eon 3 c# visual-studio-2010 winforms
我尝试了我在这个帖子上找到的东西,但没有完全按照我想要的方式工作......我有一个名为photos它的文件夹may有图片或没有.在picture's name是matriculation客户端的.我需要传递matriculationas parameter并检查是否有一个picture带有matriculation我传递的名称parameter
我试过这个:
public void VerifyPhoto(string matriculation)
{
string path = Txt_PhotosPath.Text;
var file = Directory.GetFiles(path, matriculation + ".jpg");
}
Run Code Online (Sandbox Code Playgroud)
我怎么检查它是否找到了图片?我试图比较这个,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;
Run Code Online (Sandbox Code Playgroud)
if (File.Exists(Path.Combine(path, matriculation + ".jpg"));
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1256 次 |
| 最近记录: |