0

I've found that C++ / CLI handles isn't neccessary to delete, but when I use XML Reader to load XML to memory and than try to save edited XML it sometimes failed. Can anyone describe me why? Or when is required to use delete and when not? On MSDN I've found that XmlReader::Close should release any resources held during reading. But sometimes it obviously doesn't.

XmlTextReader^ reader = gcnew XmlTextReader(filename);
XmlDocument^ doc = gcnew XmlDocument();
doc->Load(reader);
reader->Close();
...
doc editing
...
doc->Save(filename); //failed here
scarabeus
  • 43
  • 3
  • 1
    `failed here`: Failed how? File not written at all, file written with wrong contents, exception, hard drive crash, Windows crashed, computer caught on fire, what? – David Yaw Jul 22 '16 at 17:53
  • sorry I forgot it throw an exception - The process cannot access the file 'filename' because it is being used by another process – scarabeus Jul 25 '16 at 08:35

0 Answers0