Esempio n. 1
0
    //创建jsonfile
    public static void BuildlerJsonFile(DirectoryInfo di, string pingString, string filename, string suffix)
    {
        //Debug.Log("选择文件截取" + substr);
        string ProfilePath = PathMgr.GetTextFilePath();

        //Debug.Log("资源文件路径" + ProfilePath);
        ////创建资源文件
        if (!Directory.Exists(ProfilePath))
        {
            Debug.Log("资源文件不存在" + ProfilePath);
            Directory.CreateDirectory(ProfilePath);
        }

        FileStream   fs         = CreateFile(ProfilePath, filename);
        string       jsonString = FileListToJsonStr(di, pingString + PathHua, suffix);
        StreamWriter sw         = new StreamWriter(fs, Encoding.UTF8);

        try
        {
            sw.Write(jsonString);
            sw.Flush();
        }
        catch (IOException e)
        {
            Debug.Log(e.ToString());
            Debug.Log("创建失败");
        }
        finally
        {
            sw.Close();
            fs.Close();
        }
        Debug.Log("创建成功");
    }
Esempio n. 2
0
    public static void TestReadFile(string ProFileName)
    {
        string       filePath = PathMgr.GetTextFilePath() + PathMgr.PathHua + ProFileName + ".json";
        StreamReader sr       = new StreamReader(filePath);
        string       json     = sr.ReadToEnd();

        Debug.Log(json);

        JsonData jd = JsonMapper.ToObject(json);

        foreach (JsonData item in jd)
        {
            Debug.Log(item["Type"] + "-" + item["PathName"]);
        }
    }