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
4
Question by Subliminalman · Feb 26, 2013 at 07:33 AM · iosdatapath

How to write subfolders to PersistentDataPath iOS

So at runtime I need to be able to store downloaded data on the iOS device so I can use at later times. I want to keep things organized so I don't have to use a weird naming convention.

How can I create a subdirectory in Application.PersistentDataPath for iPhone?

I thought I could do something like this but I get a error through xcode saying it can't find the directory.

 string path = Application.persistentDataPath +"/localData/" + character.Name + ".xml";
 StreamWriter fileWriter = File.CreateText(path);
 fileWriter.WriteLine("Hello world");
 fileWriter.Close();  

 Debug.Log(File.ReadAllText(path));


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

2 Replies

· Add your reply
  • Sort: 
avatar image
10
Best Answer

Answer by Subliminalman · Feb 27, 2013 at 05:41 AM

Thanks danny but I a different way to do it and forgot to update this.

Here's what I did if anyone needs to know

DirectoryInfo dirInf = new DirectoryInfo(Application.persistentDataPath + "/" + "localPet"); if(!dirInf.Exists){ Debug.Log ("Creating subdirectory"); dirInf.Create();
}

Comment
Add comment · 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
0

Answer by dannyskim · Feb 26, 2013 at 05:25 PM

Try:

 string path = Application.dataPath + "/Raw/" + fileName;
Comment
Add comment · Show 3 · 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 dannyskim · Feb 27, 2013 at 04:34 PM 0
Share

Please change your comment into an answer and mark it as the right one then.

avatar image liszto · Feb 28, 2013 at 06:40 AM 0
Share

Yeah please to really close this topic ;)

avatar image booferei · Dec 17, 2017 at 01:24 PM 0
Share

Using slash (/) directly works, but consider using Path.Combine ins$$anonymous$$d:

string subdir = Path.Combine(Application.persistentDataPath, "localData");

string filepath = Path.Combine(subdir, character.Name + ".xml");

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

12 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

Related Questions

Application.dataPath + "/Raw" not loading texture on iOS? 0 Answers

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Difference between Application.persistantDataPath Vs Application.dataPath 2 Answers

IOS cant move file from cache path 0 Answers

Elements of Canvas with Constant Physical Size doesn't show up in iOS Simulator 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