Пример #1
0
 public void CreateTxt(string TxtName, string Text, PathObj HowPath)
 {
     if (!File.Exists(HowPath.Path))          //資料夾是否存在
     {
         AddDirectory(HowPath);
     }
     using (StreamWriter sw = File.CreateText(HowPath.Path + "/" + TxtName + ".txt")) {
         sw.WriteLine("\"user\":" + Text);
     }
 }
Пример #2
0
    //void Start () {
    //	print ("dataPath:"+Application.dataPath);
    //	print ("persistentDataPath:"+Application.persistentDataPath);
    //	print ("temporaryCachePath:"+Application.temporaryCachePath);
    //	print ("streamingAssetsPath:"+Application.streamingAssetsPath);
    //}

    public string GetTxt(PathObj HowPath)       //沒有檔名的話叫找資料夾中第一個看到的txt當目標
    {
        if (!File.Exists(HowPath.Path))
        {
            AddDirectory(HowPath);
        }
        foreach (string i in Directory.GetFiles(HowPath.Path))
        {
            if (i.EndsWith(".txt"))
            {
                return(File.ReadAllText(i));
            }
        }
        return("");
    }
Пример #3
0
 public string GetTxt(string TxtName, PathObj HowPath)
 {
     print("aaa");
     if (!File.Exists(HowPath.Path))
     {
         AddDirectory(HowPath);
     }
     if (File.Exists(HowPath.Path + "/" + TxtName + ".txt"))
     {
         return(File.ReadAllText(HowPath.Path + "/" + TxtName + ".txt"));
     }
     else
     {
         return("");
     }
 }
Пример #4
0
 public void DeleteTxt(string TxtName, PathObj HowPath)
 {
     File.Delete(HowPath.Path + "/" + TxtName + ".txt");
 }
Пример #5
0
 public void AddDirectory(PathObj HowPath)       //產生資料夾 如我資料夾已經存在不會傷害資料夾中的檔案
 {
     Directory.CreateDirectory(HowPath.Path);
 }