Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 Christopher Winstanley · Sep 26, 2010 at 09:30 PM · iphoneloadingxml

Load from XML on iPhone

Hi Everyone,

I am having trouble loading from XML on the iPhone. Here is the code:

function LoadXML()
{
   var r : StreamReader = File.OpenText(docPath+"/highscores.xml");
   var _info : String = r.ReadToEnd();
   r.Close();
   line=_info;
   highscores = line.Split("%"[0]);
   Debug.Log("File Read");
}

Here is the error I am getting:

DirectoryNotFoundException: Could not find a part of the path "/var/mobile/Applications/F0571EFE-3482-4183-8A8B-4F3498FB14FD/terraslam.app/highscores.xml".

I am placing the xml file straight in the assets folder. Where should I be putting it? or is the code wrong?

For reference this is also the code I am going to use to write to the XML. I am assuming this is wrong as well if the first bit is.

function CreateXML()
{
   var writer : StreamWriter;
   var t : FileInfo = new FileInfo(docPath+"/highscores.xml");
   if(!t.Exists)
   {
      writer = t.CreateText();
   }
   else
   {
      t.Delete();
      writer = t.CreateText();
   }
   writer.Write(lineToWrite);
   writer.Close();
   scoreText.text = "File written.";
}

Any help appreciated!!!

Thanks

Chris

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

1 Reply

· Add your reply
  • Sort: 
avatar image
3

Answer by Dreamora · Sep 27, 2010 at 12:31 AM

the path is totally wrong I fear, that path is not writeable at all. On the iphone you only have 2 folders you can write to: The apps document folder and the apps cache folder

if you want the file to be writeable you must create it yourself manually in the applications Docs directory. There are a few threads on the board and potentially also some answers here on how to generate the applications doc path from the dataPath and I additionally posted some short native code for objc - uikit to return the real one (the example there though is for the cache path, but the docs is the same with the constant replaced) directly as provided by iOS which will always, independent of changes on unity and iOS, give you the correct code.

Comment
Add comment · Show 2 · Share
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
avatar image Christopher Winstanley · Sep 27, 2010 at 10:41 AM 0
Share

I've been looking around now for examples but to no avail do you have an example you could give me on this thread

avatar image leith · Oct 11, 2010 at 12:59 AM 2
Share

I think this is the one he's referring to:

http://answers.unity3d.com/questions/11462/unity-iphone-can-i-store-data-on-the-iphone-to-be-used-later

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

No one has followed this question yet.

Related Questions

Large memory footprint increase when assigning a GUITexture from a WWW Object on iPad 1 Answer

Large level loading best practices 1 Answer

WWW.LoadFromCacheOrDownload not working 1 Answer

ipone issue in saving the game progress in xml files 1 Answer

How to Store Large Amounts of Static Data? 0 Answers


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