I have found couple of questions in these posts which are near to my problem but I see no answers. I am copying from streaming assets to a directory in an Android version. My copy method works for text files but fails for some jpg images I want to copy over.
The setup code:
var dir_path2 = Path.Combine(Application.persistentDataPath, "saved_images");
Directory.CreateDirectory(dir_path2);
ReadFromStreamingAssets("saved_images/spectrum_blue");
File.WriteAllText(Application.persistentDataPath + "/saved_images/spectrum_blue", stream_result);
Debug.Log("stream_result for spectrum_blue:"+stream_result);
The ReadFromStreamingAssets code:
public static void ReadFromStreamingAssets(string file_ref)
{
var full_path = Path.Combine(Application.streamingAssetsPath, file_ref);
Debug.Log("full_path at start of ReadFromStreamingAssets"+full_path);
if (full_path.Contains("://") || full_path.Contains(":///"))
{
WWW www = new WWW(full_path);
while (!www.isDone) { }
stream_result = www.text.Trim();
Debug.Log("TRIM");
}
else
{
Debug.Log("full_path:"+full_path);
stream_result = File.ReadAllText(full_path);
}
}
This method works for everything but jpegs. When I run on a jpeg I get 0 length files created. I’m hoping there’s some magic line of code to replace: stream_result=www.text.Trim() because that is
exactly where the problem seems to occur. The docs say something about bytes property but I
can’t seem to hit on right combination of letters (I often think coding is partially a random walk through murky shadows). Thanks for any help!