how to load textasset from mobile persistentdatapath?

on editor it works like:
data2 = Resources.Load(“rank2”);

but on mobile i cant read it. i have tried like
data2 =Application.persistentDataPath + “/rank2.csv” ;
data2 =Application.persistentDataPath + “/rank2” ;
i have also tried
string path = Application.persistentDataPath + “/rank2.csv”;
if (File.Exists(path))
{
Debug.Log(“finds file”);
}
and checked the file exists…

You cannot read Unity’s TextAsset files that way. Unity mungles them into something that is universally efficient for the engine.

Instead do this:

public TextAsset RankFile;

and drag the rank2.csv file in there.

Then to get at it, just use:

string data = RankFile.text;

i just cant drag it, i need to download it on my mobile first. it goes to persistentdatapath

Can’t you save the text to text file and read it using File class?

If the above is true, then you are NOT doing this:

Those two things are completely and totally unrelated and absolutely NOTHING to do with each other.

Download, write and read files using System.IO.File commands and this:

OR…

Use Resources.Load() only as indicated below:

https://docs.unity3d.com/ScriptReference/Resources.Load.html

You absolutely MAY NOT mix and match those in any meaningful way.

anybody got an actual update to this like I’m trying to load a csv as a text asset from persistentDataPath not from the resources folder as I need it read and writeable but still be used as a text asset

Please don’t hijack other threads with vague incomplete questions.

Start your own post, it’s FREE.

If you have an actual problem it will be necessary for you to communicate FAR more effectively.

Here is how to report your problem productively in the Unity3D forums:

http://plbm.com/?p=220

This is the bare minimum of information to report:

  • what you want
  • what you tried
  • what you expected to happen
  • what actually happened, especially any errors you see
  • links to documentation you used to cross-check your work (CRITICAL!!!)

If you post a code snippet, ALWAYS USE CODE TAGS:

How to use code tags: https://discussions.unity.com/t/481379

Just go run the sample code in the documentation. It works.