少年修仙传客户端基础资源
client_Hale
2018-09-05 976f9266cfae78a36c812b5c3aba4dc664e607f7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.IO;
 
namespace UnityEditor.XCodeEditor
{
    public partial class XClass : System.IDisposable
    {
 
        private string filePath;
 
        public XClass(string fPath)
        {
            filePath = fPath;
            if( !System.IO.File.Exists( filePath ) ) {
                    Debug.LogError( filePath +"路径下文件不存在" );
                    return;
            }
        }
 
 
        public void WriteBelow(string below, string text)
        {
            StreamReader streamReader = new StreamReader(filePath);
            string text_all = streamReader.ReadToEnd();
            streamReader.Close();
 
            int beginIndex = text_all.IndexOf(below);
            if(beginIndex == -1){
                Debug.LogError(filePath +"中没有找到标致"+below);
                return; 
            }
 
            int endIndex = text_all.LastIndexOf("\n", beginIndex + below.Length);
 
            text_all = text_all.Substring(0, endIndex) + "\n"+text+"\n" + text_all.Substring(endIndex);
 
            StreamWriter streamWriter = new StreamWriter(filePath);
            streamWriter.Write(text_all);
            streamWriter.Close();
        }
 
        public void Replace(string below, string newText)
        {
            StreamReader streamReader = new StreamReader(filePath);
            string text_all = streamReader.ReadToEnd();
            streamReader.Close();
 
            int beginIndex = text_all.IndexOf(below);
            if(beginIndex == -1){
                Debug.LogError(filePath +"中没有找到标致"+below);
                return; 
            }
 
            text_all =  text_all.Replace(below,newText);
            StreamWriter streamWriter = new StreamWriter(filePath);
            streamWriter.Write(text_all);
            streamWriter.Close();
 
        }
 
 
 
 
        public void Dispose()
        {
 
        }
    }
}