Can't write to Application.persistantDataPath

Hello there.

Since some patch, I can’t write anything on the Application.persistantDataPath folder. My system worked well until something went horribly wrong somewhere.

In the player setting, the Install Location is set to internal, the Write Access to External (SD Card).
When I use logcat, the save location is /storage/emulated/0/Android/data/com.mycompany.mygame/files/

I don’t have any Manifest.xml in the Assets/Plugins/Android/

The code I use to write stuff is this one :

    public static void Write(string filename, string content)
    {
        if(Application.platform == RuntimePlatform.Android)
        {
            filename = Path.Combine(Application.persistentDataPath, filename);
        }

        string directory = Path.GetDirectoryName(filename);
        Debug.Log (directory);
        if(!Directory.Exists(directory))
        {
            Directory.CreateDirectory(directory);
        }

        FileStream file = File.Open(filename, FileMode.CreateNew);
        StreamWriter sw = new StreamWriter(file);

        sw.Write(content);

        sw.Close();
        file.Close();
    }

And I can’t figure out what’s missing…

I’m using Unity 4.6.2p1

No changes in Unity 4.6.3. Does anyone have an idea? A tip? Something? :confused:

This stuff si driving me crazy… Anyone? :frowning:

Are any exceptions thrown when you do the directory creation or file writing? For example, a snippet from my game:

            try
            {
                Directory.CreateDirectory( baseSave + dir );
            }
            catch ( System.Exception e )
            {
                Debug.LogError( e.ToString() );
                return;
            }

I found my problem, it is just how I don’t know enough about android itself.

The phone was in USB Drive mode, and show me the true SDCard slot instead of the internal memory. But my app saved the stuff in the internal memory so I couldn’t see it. I changed the device USB to MTP mode and I could see my files.

I’m just a noob. :frowning: