Quantcast
Channel: conversion of atom feed to rss feed - Stack Overflow
Viewing all articles
Browse latest Browse all 2

Answer by Greg Beech for conversion of atom feed to rss feed

$
0
0

For performance reasons, many of the *Writer classes in .NET buffer their output; that is they do not write straight to the output device but keep some of the data in memory until it hits a threshold size. When you close/dispose the writer, then it knows you are finished with it, and will flush any buffered data to the output.

Here, you create an XmlWriter but you are never closing or disposing it, so it probably still has buffered content that is never flushed, hence the incomplete file. You're also leaving expensive resources open for longer than is necessary by not disposing it.

Surround your instantiations of classes implementing IDisposable with a using block, for example:

using (XmlWriter writer = XmlWriter.Create(rssFileName)){    rss2.WriteTo(writer);}

This will call the Dispose method on the writer at the end of the block, and flush the content. You should also surround the instantiation of XmlReader with a using block.


Viewing all articles
Browse latest Browse all 2

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>