'Error trying to use a pdf file located in my project folder
I am making an application which inserts text into a pdf template, but I am encountering a problem and it is that when I want to use the template it is as if I could not find it, so I did a validation with File.Exists, and it effectively returns me false, but when I look for the same path in the file explorer it finds me the pdf without problems. This is my code:
protected void btn_Guardar_Click(object sender, EventArgs e)
{
try
{
string newName = $"numdoc_{ddl_TipoCapacitacion.SelectedValue}-{lastId.Rows[0]["ID"]}-{DateTime.Now.ToString("dd/MM/yyyy").Replace("/", String.Empty)}.pdf";
file = Path.Combine(location, newName);
string oldFile = string.Concat(Server.MapPath($@"~/plantillasPdf/capacitaciones/plantillaDiploma.pdf"));
string newFile = string.Concat(Server.MapPath($@"~/plantillasPdf/capacitaciones/{newName}"));
if (!File.Exists(oldFile))
{
}
PdfReader reader = new PdfReader(oldFile);
...
catch (Exception ex)
{
ControlarExcepcion(ex);
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
