Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

System.IO.FileNotFoundException

$
0
0

I am trying to read Xml file through XmlReader but it gives exception as System.IO.FileNotFoundException: Could not find file "/Perls.xml".Following is my code:

using (XmlReader reader = XmlReader.Create("Perls.xml"))
{
while (reader.Read())
{

                    if (reader.IsStartElement())
                    {

                        switch (reader.Name)
                        {
                        case "perls":

                            System.Diagnostics.Debug.WriteLine("Start <perls> element.");
                            break;
                        case "article":

                            System.Diagnostics.Debug.WriteLine("Start <article> element.");

                            string attribute = reader["name"];
                            if (attribute != null)
                            {
                                System.Diagnostics.Debug.WriteLine("  Has attribute name: " + attribute);
                            }

                            if (reader.Read())
                            {
                                System.Diagnostics.Debug.WriteLine("  Text node: " + reader.Value.Trim());
                            }
                            break;
                        }
                    }
                }

Viewing all articles
Browse latest Browse all 58056

Trending Articles



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