unity[pc]在本地创建一个txt文本文件并写入内容

   void Start()
    {
        loadpath = "F:/3/";
        print(Directory.Exists(loadpath));
        if (!Directory.Exists(loadpath))
        {
            Directory.CreateDirectory(loadpath);
        }
        WriteFile(loadpath + "23.txt", 1, "sdsadsda");
        if (!File.Exists(loadpath + "sb.txt"))
        {
            File.Create(loadpath + "sb.txt");
        }

    }
    void WriteFile(string fileName,int linenumber,string tex)
    {
        string[] str = File.ReadAllLines(fileName);
        if (linenumber != 0)
        {
            str[linenumber - 1] = tex;
            string[] ssss = new string[] { "SSSSSSSSSSSSSSSSSSSSSSSS" ,"wffklfjlad"};
            File.WriteAllLines(fileName, ssss);

        }
    }

 

你可能感兴趣的:(c#)