I have to print some documents, but when it comes to a document that does not exist it stops printing I need to be able to print it if it does not find it skip to the next field and continue printing the others
public class imprimirmanifiesto
{
public void imprimir(string dobleslash)
{
Process p = new Process();
p.StartInfo = new ProcessStartInfo()
{
FileName = "C:\Users\bodega\Documents\Manifiestos\" + dobleslash + ".pdf",
UseShellExecute = true,
Verb = "printto",
CreateNoWindow = true,
WindowStyle = ProcessWindowStyle.Hidden,
//Arguments = printer,
};
p.Start();
}
}
Button
private void button2_Click_1(object sender, EventArgs e)
{
r = new imprimirmanifiesto();
int pos = 0;
bool a = true;
try
{
foreach (DataGridViewRow row in dataGridView1.Rows)
{
if (!row.Cells[1].Value.ToString().Contains("-1"))
r.imprimir(row.Cells[1].Value.ToString());
}
}
catch (Exception q)
{
//MessageBox.Show("Verifique número de importación y seleccione un tipo");
}
}