1
pulg
2025-05-14 5a640911f7e7ef3a003775993f077e1a0e9ac130
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
using Newtonsoft.Json.Linq;
using Newtonsoft.Json;
using NLog.Fluent;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace HH.WCS.HGXCL.util
{
    public class JsonHelper
    {
        public static string GetValue(string name)
        {
            try
            {
                var jsonFile = System.AppDomain.CurrentDomain.BaseDirectory+ "json\\Config.json";
                using (System.IO.StreamReader file = System.IO.File.OpenText(jsonFile))
                {
                    using (JsonTextReader reader = new JsonTextReader(file))
                    {
                        JObject o = (JObject)JToken.ReadFrom(reader);
                        var value = o[name].ToString();
                        return value.Replace("\r\n", "");
                    }
                }
            }
            catch (Exception ex)
            {
                return "-1";
            }
        }
    }
}