Below is the code for file delete:
public void ConvertImageToPdf(string ImageLocation,string SaveFilePath,string TypeDoc) { Document document = new Document(); using (var stream = new FileStream(SaveFilePath, FileMode.Create, FileAccess.Write, FileShare.None)) { PdfWriter.GetInstance(document, stream); document.Open(); using (var imageStream = new FileStream(ImageLocation, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { //System.Drawing.Image img = System.Drawing.Image.FromFile(ImageLocation); var images = iTextSharp.text.Image.GetInstance(imageStream); images.ScaleAbsolute(500f,300f); Paragraph pr = new Paragraph(TypeDoc); //System.Drawing.Image image = resizeImage(img, new Size(200, 200)); // image.Width = 300; document.Add(pr); document.Add(images); if (document != null) { Console.WriteLine("Succesfull"); File.Delete(ImageLocation); } } document.Close(); } }