Quantcast
Channel: Questions in topic: "error message"
Viewing all articles
Browse latest Browse all 2891

Can't create file: "File is inaccesible due to its protection level" [SOLVED]

$
0
0
Hello everyone, I'm new in Unity. I'm trying to create some .json files but when I use the "File.*" expression this return me this error: 'File' is inaccessible due to its protection level. I have searched for access method error but I can't find nothing. What I can do? Thanks for the help. Here the code: using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.IO; public class TestWriter : MonoBehaviour { [System.Serializable] public class InfoPlayer { public string name; public float health; } public InfoPlayer player = new InfoPlayer(); public void OutputJSON() { string output = JsonUtility.ToJson(player); string path = Application.dataPath+"/text.json"; print(path); File.WriteAllText(path,output); } }

Viewing all articles
Browse latest Browse all 2891

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>