Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by TheShadyColombian · Mar 26, 2017 at 08:09 PM · c#xmlpathfilesstorage

IsolatedStorageException when creating new XmlDocument variable only on android build.

When I run my build on android, I receive an IsolatedStorageException when I try to call

 XmlDocument doc = new XmlDocument ();

The exception says "Could not find part of the path", but I am not passing a path at all, and since I'm not loading or saving the file, I don't see why a path would be needed anyway. The path is pointing to /data/app/[game's identifier]/base.apk/SaveDataTemplate.xml

Here's the full script, as well as a screencap of my Device's screen which has a shitty little debugger containing the last error in the file modifying process, since my phone's cable isn't playing nice with ADB. The bug apparently is coming from line 102 of LevelDataCollection.cs:

 //File: LevelDataCollection.cs
 
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 #if UNITY_EDITOR
 using UnityEditor;
 #endif
 using System.Xml;
 using System.Xml.Serialization;
 using System.IO;
 
 [XmlRoot ("LevelCollection")]
 public class LevelDataCollection {
 
     [XmlArray ("Levels")]
     [XmlArrayItem ("Level")]
     public List<LevelData> Levels = new List<LevelData> ();
 
     //If it doesn't work, try adding System.IO. to the beginning of Path.Combine
     public static string dataPath = "Levels";
     public static string saveDataTemplatePath = Path.Combine (Application.dataPath, "SaveDataTemplate.xml");
 
     public static LevelDataCollection Load (string path) {
 
         StringReader reader = null;
         XmlSerializer Serializer = null;
 
         try {
 
 
             TextAsset LevelContainerXML = (TextAsset)Resources.Load (path);
 
             XmlDocument xmldoc = new XmlDocument ();
             xmldoc.LoadXml (LevelContainerXML.text);
 
             Serializer = new XmlSerializer (typeof (LevelDataCollection));
 
             reader = new StringReader (LevelContainerXML.text);
 
         } catch (System.Exception e) {
             
             Debug.LogError (e + "\nCould not find file at " + Path.GetFullPath (path));
             return null;
 
         }
 
         LevelDataCollection levelCollection = Serializer.Deserialize (reader) as LevelDataCollection;
 
         reader.Close ();
 
         UpdateSaveDataTemplate (saveDataTemplatePath, levelCollection.Levels);
 
         GameObject.Find ("DebugLine").GetComponent<UnityEngine.UI.Text> ().text = "Loading level data from " + Path.GetFullPath (path);
 
         return levelCollection;
 
     }
 
     public override string ToString () {
 
         string compilation = "";
 
         foreach (LevelData data in Levels){
             compilation += "\n";
             compilation += data;
         }
 
         return compilation;
 
     }
 
     //Since there might not be a save file, we need to create an xml file that will be used as a blank template
     public static void UpdateSaveDataTemplate (string templatePath, List <LevelData> dataToClone) {
 
         LevelSaveDataCollection collection = new LevelSaveDataCollection ();
 
         collection.Levels = new List<LevelSaveData> ();
         int i = 0;
         while (collection.Levels.Count < dataToClone.Count) {
             collection.Levels.Add (new LevelSaveData (dataToClone[i].ID.ToString() + ":" + dataToClone[i].SubID.ToString(), i == 0, false));
             i++;
 
         }
 
         XmlSerializer Serializer = new XmlSerializer (typeof (LevelSaveDataCollection));
 
         if (!File.Exists (templatePath))
             CreateNewStandardXML (templatePath);
 
         FileStream file = new FileStream (templatePath , FileMode.Truncate);
 
         Serializer.Serialize (file, collection);
 
         file.Close ();
 
         Debug.Log ("Template save data XML successfully created at " + file.Name + "! VVV\n\n" + collection);
 
     }
 
     public static void CreateNewStandardXML (string path) {
 
         // Create the XmlDocument.
         XmlDocument doc = new XmlDocument ();
         doc.LoadXml ("<LevelSaveDataCollection></LevelSaveDataCollection>"); //XML document content (empty, as we just want a basic file);
 
         // Save the document to a file and auto-indent the output.
         XmlTextWriter writer = new XmlTextWriter (path, null);
         writer.Formatting = Formatting.Indented;
         doc.Save (writer);
         writer.Close ();
     
     }
 
 }
 

Screencap Here (Image button wasn't working so I had to use a link instead :P )

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

295 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Transform not translating accross path, GL.Begin(GL.LINES) isn't working properly, a few more problems... 0 Answers

[SOLVED] Problem with random generated path for 2D game 2 Answers

File.Move wont work , error. IOException: Win32 IO returned ERROR_ALREADY_EXISTS. Path: 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges