How do I free my pdf file from the previous process in .Net core? RRS feed

  • Question

  • User-449871658 posted

    I have created PDF file using itextsharp. while attaching to the email or file deleting it gives me this error :

    Your file is used by another process, you cannot delete or attach it

    Wednesday, January 18, 2017 7:43 AM


  • User197322208 posted

    Search on all objects from iTextSharp that the code is using and find if they implements IDisposable

    Use either


    syntax , either  call


    ( for example, PDFWriter, as I know, it is IDisposable - or it is inherited from a class that is IDisposable)

    Also, do this for streams in .NET

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, January 18, 2017 8:24 AM