Reading XML working in my computer but not in my Android phone

Hello friends,

Following code works perfectly in my computer but when I try to run it in my Android Phone, it does not work.

     string path = @"Assets\Layout\XML\file" + select.ToString() + @".xml";
     XmlSerializer xmlSerializer = new XmlSerializer(typeof(List<Name>));
     StreamReader sr = new StreamReader(path);
     List<Name> listnames = (List<Name>)xmlSerializer.Deserialize(sr);

How can I make the code work in my Android Phone?

I almost gave up but finally solved it. Unity converts everything to binary variable so that the first thing you need to do is to convert all xml files you have to txt and copy them to “Assets/Resources” folder.

Then, you can use following code:

    TextAsset asset = Resources.Load("file" + select.ToString()) as TextAsset;
    Stream s = new MemoryStream(asset.bytes);
    BinaryReader br = new BinaryReader(s);

    XmlSerializer xmlSerializer = new XmlSerializer(typeof(List<Name>));
    StreamReader sr = new StreamReader(s);
    List<Name> listnames = (List<Name>)xmlSerializer.Deserialize(sr);