Load and save XML file (not embedded)

Hi, I need to load and save an xml file with score information to create a scoreboard of my game (Android, iOS and WP81).
I tried using the 'Working with files' sample and it works good loading an embedded file but it's not possible to write an embedded file so I need to use a non embedded file.
I added my file to the Content folder of the projects (without any subfolder), I also set the content root directory to 'Content'

My current code is this: filename = "scores_medium.xml"; var assembly = typeof(ScoreboardScene).GetTypeInfo().Assembly; // assembly.GetManifestResourceNames() returns no resources using (Stream stream = assembly.GetManifestResourceStream(filename)) // stream is null after this line -> runtime error { using (var reader = new StreamReader(stream)) { var serializer = new XmlSerializer(typeof(List<Score>)); scores = (List<Score>)serializer.Deserialize(reader); reader.Dispose(); } }

I don't understand if I need to use assembly for non embedded files. I search a lot in the forums and in google, they always talk about embedded resources but since I need to write on the file and save it I need it to be non embedded.

Answers

  • DirkWilhelmDirkWilhelm USMember ✭✭✭
  • MarkedOneMarkedOne ARMember ✭✭

    "PCL Storage is stored Folder and files temporarily. If app is closed, cached data cleared automatically."
    Thank you but I need the program to read an existing xml file with data, modify it and save it again (scoreboard system). The xml is in "Content/xml/" folder in my projects, and PCLStorage reads and write in a local device storage. I'm still searching but I'm starting to think that I will not use a scoreboard if it is so dificult to find a simple solution for this.

Sign In or Register to comment.