Hi NicholasPiazza-0093,
XmlReader implements IDisposable, so I suggest you can wrap all your code inside a using statement.
And I made test with your code, it worked fine.
Here is my code example:
private bool GetShowIntroFlag()
{
using (var reader = XmlReader.Create(@"C:\Users\Desktop\test.xml"))
{
reader.MoveToContent();
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Element &&
reader.Name == "noShowIntro")
{
_ = reader.Read();
if (reader.NodeType == XmlNodeType.Text)
{
switch (reader.Value.ToLower())
{
case "false":
return false;
case "true":
return true;
default:
throw new FileFormatException
(string.Format
($"Unknown noShowIntro value {reader.Value.ToLower()}"));
}
}
}
}
}
return false;
}
Best Regards,
Daniel Zhang
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.