最近在写游戏的时候,用到很多读取和写入,现在就带大家简单的了解一下文件的读取和写入(这里我们先说文件的写入,读取我们会在下一篇说)。
我们都知道,要写一个文件或读取一个文件,必须知道文件的路径。
这里我们就以Unity为例,Unity中获取路径的方法:
Application.dataPath(数据路径)
Application.temporaryCachePath(临时路径)
Application. persistentDataPath
(持久数据路径
)
废话先不多说上代码:
using UnityEngine;
using System.Collections;
using System.IO;
using System.Text;
using System;
public class writeTxT : MonoBehaviour {
void Start(){
string name=”write.t