|  |  |  | 
|---|
|  |  |  | string[] sArray = msg3.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); | 
|---|
|  |  |  | string msg1 = sArray[0].ToString(); | 
|---|
|  |  |  | string user = sArray[1].ToString(); | 
|---|
|  |  |  | string HPath = sArray[2].ToString(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | string filePath = "Configuration"; | 
|---|
|  |  |  | string filePath = "MESConfiguration"; | 
|---|
|  |  |  | bool isAppend = true; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | filePath = $@"{filePath}\PlateBinding.txt"; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | filePath = "D:\\" + filePath; | 
|---|
|  |  |  | //filePath = "C:\\" + filePath; | 
|---|
|  |  |  | filePath = HPath; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (!System.IO.Directory.Exists(Path.GetDirectoryName(filePath))) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | [Route("Get/Xt_PlateBinding")] | 
|---|
|  |  |  | [HttpGet] | 
|---|
|  |  |  | public object Get(string user) | 
|---|
|  |  |  | public object Get(string user,string HPath) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | try | 
|---|
|  |  |  | { | 
|---|
|  |  |  | //判断是否存在文件夹,若不存在则创建 | 
|---|
|  |  |  | if (!System.IO.Directory.Exists(Path.GetDirectoryName(HPath))) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | System.IO.Directory.CreateDirectory(Path.GetDirectoryName(HPath)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //判断是否已经存在平板绑定文件,若不存在则创建一份文件 | 
|---|
|  |  |  | bool fileExists = System.IO.File.Exists(HPath); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //不存在则创建该文件 | 
|---|
|  |  |  | if (!fileExists) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | bool isAppend = true; | 
|---|
|  |  |  | using (StreamWriter writer = new StreamWriter(HPath, isAppend)) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | //存在的时候才写一行 | 
|---|
|  |  |  | if (fileExists && isAppend) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | writer.WriteLine(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | string msg1 = ""; | 
|---|
|  |  |  | var content = msg1 is string ? msg1 : JsonConvert.SerializeObject(msg1); | 
|---|
|  |  |  | writer.WriteLine($"{DateTime.Now}"); | 
|---|
|  |  |  | writer.WriteLine(""); | 
|---|
|  |  |  | msg1 = msg1.Replace("{", "").Replace("}", "").Replace("\"", ""); | 
|---|
|  |  |  | string[] arr = msg1.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); | 
|---|
|  |  |  | for (int i = 0; i < arr.Length; i++) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | writer.WriteLine(arr[i]); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //根据指定路径,读取文件内容,返回数据为数组格式 | 
|---|
|  |  |  | string[] ConfigFileInfo = File.ReadAllLines(@"D:\Configuration\PlateBinding.txt"); | 
|---|
|  |  |  | string[] ConfigFileInfo = File.ReadAllLines(HPath); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | objJsonResult.code = "1"; | 
|---|
|  |  |  | objJsonResult.count = 1; | 
|---|