none
System.IO.IOException: 'The process cannot access the file 'x' because it is being used by another process.'

    Question

  • Sorry my English :)

    There is code

    var doc = PresentationDocument.Open(@"d:\temp.pptx", true);    
    //... proccess presentation
    doc.SaveAs(@"d:\temp2.pptx");
    doc.Close();
    
    var doc2 = PresentationDocument.Open(@"d:\temp2.pptx", false);
    doc2.Close();

    I can not understand why happend that

    System.IO.IOException: 'The process cannot access the file 'x' because it is being used by another process.'

    mardi 10 avril 2018 08:22

Réponses

Toutes les réponses

  • Hello adamShakhabov,

    Check if the file is opened in word or if it is opened in OpenXML SDK Tool.

    Best Regards,

    Terry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    mardi 10 avril 2018 09:48
    Modérateur
  • Check if the file is opened in word or if it is opened in OpenXML SDK Tool.

    No, temp2.pptx is new file which created my code.
    mardi 10 avril 2018 09:53
  • Hello adamShakhabov,

    >>doc.SaveAs(@"d:\temp2.pptx");

    doc should a PresentationDocument object and PresentationDocument does not have a SaveAs function, so I'm wondering how do you run your code. 

    I would suggest you share a simply project file so we could use it to reproduce your issue directly. Please remember remove any sensitive information before sharing the project.

    For sharing file, you could share the file via Cloud Storage, such as One Drive, and then put link address here. Thanks for understanding.

    Best Regards,

    Terry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    mercredi 11 avril 2018 02:42
    Modérateur
  • I noticed that doc.SaveAs() return object, which I closed just

    var savedDoc = doc.SaveAs(@"d:\temp2.pptx") as PresentationDocument;
    
    savedDoc.Close();


    • Marqué comme réponse adamShakhabov mercredi 18 avril 2018 12:41
    • Modifié adamShakhabov mercredi 18 avril 2018 12:42 edited format
    mercredi 18 avril 2018 12:41