In my database I have a field that is the guide number, and that same one is also an image name ( .jpg
or .tif
). The topic, that I have cases where the guide number has several images and in the folder of images you can appear like this:
nro_guia: GUIA00020---->> BASE DE DATOS
GUIA00020__28042017165654.tif -------->>CARPETA DE IMAGENES
How can I do to be able to validate the existence of the image of that guide?
foreach (DataRow row in dtImagenes.Rows)
{
string nom_imagen_db =
row["NroGuia"].ToString().TrimEnd(' ');
var ruta_imagen = Path.Combine(txt_ruta.Text,
nom_imagen_db + ".tif");
var ruta_imagen_2 = Path.Combine(txt_ruta.Text,
nom_imagen_db + ".jpg");
if (pgb_cargando.Value <= cantidad_imagen_db)
{
pgb_cargando.PerformStep();
}
if (!File.Exists(ruta_imagen) &&
!File.Exists(ruta_imagen_2)
{
string f_guia = row["FechaGuia"].ToString();
guias.InsertarGuiasValidadas(nom_imagen_db,
Convert.ToDateTime(f_guia),DateTime.Now, "NO");
}
}
This code works only if the image name is the same as the one in the guide.
I hope you can help me.
Thank you.