# How do I get Resource path on iOS devices?

**URL:** https://discussions.unity.com/t/how-do-i-get-resource-path-on-ios-devices/631430
**Category:** Mobile
**Tags:** Scripting
**Created:** [June 21, 2016, 9:16am UTC](https://discussions.unity.com/t/how-do-i-get-resource-path-on-ios-devices/631430 "2016-06-21T09:16:41Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![ChangJoo-Park](https://avatars.discourse-cdn.com/v4/letter/c/9e8a1a/32.png) [@ChangJoo-Park](https://discussions.unity.com/u/ChangJoo-Park)
#### Post date: [June 21, 2016, 9:16am UTC](https://discussions.unity.com/t/how-do-i-get-resource-path-on-ios-devices/631430/1 "2016-06-21T09:16:41Z")

</div>

Hello I use xml for databse.  
xml files are in Assets/Resources/

public static CourseContainer Load (string path)  
{  
TextAsset \_xml = Resources.Load (path);  
XmlSerializer serializer = new XmlSerializer (typeof(CourseContainer));  
StringReader reader = new StringReader (\_xml.text);  
CourseContainer courses = serializer.Deserialize (reader) as CourseContainer;  
reader.Close ();  
return courses;  
}

It works well, path is Assets/Resources/course.xml  
but save can’t. I can’t find Resource folder in iOS device

public static void Save ()  
{  
CourseContainer courses = GlobalVariableManager.courseContainer;

#if UNITY\_IOS  
XmlSerializer serializer = new XmlSerializer (typeof(CourseContainer));  
string filePath = System.IO.Path.Combine(Application.persistentDataPath, “courses.xml”);  
FileStream stream = new FileStream (filePath, FileMode.Truncate);  
serializer.Serialize (stream, courses);  
stream.Close ();  
#endif  
}

I want know where is my xml file in iOS devices.

---

<div class="post-metadata">

### Author: ![ChangJoo-Park](https://avatars.discourse-cdn.com/v4/letter/c/9e8a1a/32.png) [@ChangJoo-Park](https://discussions.unity.com/u/ChangJoo-Park)
#### Post date: [June 21, 2016, 10:10am UTC](https://discussions.unity.com/t/how-do-i-get-resource-path-on-ios-devices/631430/2 "2016-06-21T10:10:04Z")

</div>

I tried this, [How do I read XML on iPhone? - Questions & Answers - Unity Discussions](http://answers.unity3d.com/questions/132753/how-do-i-read-xml-on-iphone.html)  
read well, write can’t

---

<div class="post-metadata">

### Author: ![shaderop](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/shaderop/32/151759_2.png) [@shaderop](https://discussions.unity.com/u/shaderop)
#### Post date: [June 21, 2016, 10:21am UTC](https://discussions.unity.com/t/how-do-i-get-resource-path-on-ios-devices/631430/3 "2016-06-21T10:21:23Z")

</div>

Use [code tags](http://forum.unity3d.com/threads/using-code-tags-properly.143875/) when posting in the future.

Your problem is most probably here:

```csharp
FileStream stream = new FileStream (filePath, FileMode.Truncate);

```

**FileMode.Truncate** tells **FileStream** to throw an exception if the file you’re attempting to open doesn’t already exist. Change it to FileMode.Create:

```csharp
FileStream stream = new FileStream (filePath, FileMode.Create);

```

I think you’re issue is that you’re making an incorrect assumption. You can read files from the Resources folder, but you can’t write to it at runtime. You’re reading the file from somewhere and writing to a completely different location.[/code]
