System.IO.IOException: file used by another process

前端 未结 10 2353
囚心锁ツ
囚心锁ツ 2020-12-14 16:59

I\'ve been working on this small piece of code that seems trivial but still, i cannot really see where is the problem. My functions do a pretty simple thing. Opens a file, c

10条回答
  •  半阙折子戏
    2020-12-14 17:46

    My reputation being too small to comment an answer, here is my feedback concerning roquen answer (using settings on xmlwriter to force the stream to close): it works perfectly and it made me save a lot of time. roquen's example requires some adjustment, here is the code that works on .NET framework 4.8 :

        XmlWriterSettings settings = new XmlWriterSettings();
        settings.CloseOutput = true;
        writer = XmlWriter.Create(stream, settings);
    

提交回复
热议问题