Reputation: 2902
I am trying to find out if there is a way to calculate the file size from XmlReader. I don't see anything on the reader object that helps determine the size. Any ideas? Thank you!
Using reader As Xml.XmlReader = GetXML(columnName.ToString())
End Using
Upvotes: 5
Views: 5579
Reputation: 56556
XmlReader
might not read from something that has a known or definite size. Your best bet would be to do something with the source of whatever the XmlReader
is reading. E.g. you might have a Stream
and try to get Stream.Length
(some streams don't support this, as they don't have a length). This will require modifying GetXML
.
Upvotes: 4
Reputation: 424
If you must use XmlReader as your source, this should get you close to the file size (c#):
int sizeInBytes = Encoding.ASCII.GetBytes(reader.ReadOuterXml()).Length;
Upvotes: 1