- Home /
Visual Studio tells me I cant use File.WriteAllBytes or System.IO.File.WriteAllBytes?
This has been a bit frustrating, but likely a simple question. I'm using the correct name spaces, but it just keeps telling me I can't use anything with "File."
It will let me use System.IO.File.Create though, Does that work the same way? I'm basically just wanting to save some images on the user's device so they don't have to download them every time they see them.
Answer by chariot · Jun 02, 2016 at 02:00 PM
Here snippet for you
FileStream fls = new FileStream (Application.persistentDataPath + "/yourOwnPath/" + "nameOfFile.jpg", FileMode.Create);
fls.Write (www.bytes, 0, www.bytes.Length); //same for any byte array, just replace "www.bytes" with your variable
fls.Close ();
AND one more:
I'm basically just wanting to save some images on the user's device so they don't have to download them every time they see them.
Use asset bundles, if you download picture from www, and then save it, then at another game start app need to use again www to "download" picture from device, it's bad. Still if your game doesnt have 100 downloading objects at same time, you can use your way without fear for perfomance :)
Your answer
Follow this Question
Related Questions
Accessing local system ( File Browser ) 2 Answers
File saving error 1 Answer
Distribute terrain in zones 3 Answers
Multiple Cars not working 1 Answer
Can you change the Texture Import Settings via C# Script? 1 Answer