Unity数据保存到安卓手机目录

    string fileName;

    // Use this for initialization
    void Start()
    {
        fileName = "/sdcard/data/VRData";
        if (!Directory.Exists(fileName))
        {
            Directory.CreateDirectory(fileName);
        }


        string sb = "这是测试数据";

       // System.IO.File.WriteAllText((fileName + "/第一条.txt").ToString(), sb);

        StreamWriter sw = new StreamWriter(fileName + "/数据.txt");
        
//StreamWriter sw = new StreamWriter(fileName + "/数据.txt",true);第二个参数表示是否拼接,不会把当前的内容覆盖

sw.AutoFlush = true; sw.WriteLine("第二条\r\n"); sw.WriteLine("第三条数据\r\n"); sw.WriteLine("第四条数据\r\n"); sw.WriteLine("第五条数据\r\n"); sw.WriteLine("第6条数据\r\n"); }

 

 

你可能感兴趣的:(unity)