|
|
@@ -6,7 +6,6 @@ using System.Linq;
|
|
|
using System.Security.Cryptography;
|
|
|
using System.Text;
|
|
|
using System.Threading.Tasks;
|
|
|
-using UnityEngine;
|
|
|
|
|
|
public class FileHelper
|
|
|
{
|
|
|
@@ -47,6 +46,12 @@ public class FileHelper
|
|
|
|| (i + 1 < size && str[i + 1] == ',')))
|
|
|
{
|
|
|
isSign = !isSign;
|
|
|
+ if (i == size - 1 && !isSign)
|
|
|
+ {
|
|
|
+ endindex = i;
|
|
|
+ it = RemoveHeadandTailChar(str.Substring(startindex, endindex - startindex + 1), '"');
|
|
|
+ ret.Add(it);
|
|
|
+ }
|
|
|
}
|
|
|
else if (i == size - 1)
|
|
|
{
|
|
|
@@ -58,7 +63,59 @@ public class FileHelper
|
|
|
|
|
|
return ret.ToArray();
|
|
|
}
|
|
|
+ public static string[] SpiltCsvData(string str)
|
|
|
+ {
|
|
|
+ List<string> ret = new List<string>();
|
|
|
+
|
|
|
+ int size = str.Length;
|
|
|
+
|
|
|
+ int startindex = 0;
|
|
|
+ int endindex = 0;
|
|
|
+ bool isSign = false;
|
|
|
+ string it = null;
|
|
|
+ for (int i = 0; i < size; i++)
|
|
|
+ {
|
|
|
+ if (str[i] == ',' && !isSign)
|
|
|
+ {
|
|
|
+ if (i >= 1 && str[i - 1] == ',')
|
|
|
+ {
|
|
|
+ it = string.Empty;
|
|
|
+ ret.Add(it);
|
|
|
+ startindex = i + 1 < size ? i + 1 : i;
|
|
|
+ if (i == size - 1)
|
|
|
+ {
|
|
|
+ it = string.Empty;
|
|
|
+ ret.Add(it);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ endindex = i - 1 >= 0 ? i - 1 : 0;
|
|
|
+ it = RemoveHeadandTailChar(str.Substring(startindex, endindex - startindex + 1), '"');
|
|
|
+ ret.Add(it);
|
|
|
+ startindex = i + 1 < size ? i + 1 : i;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (str[i] == '"' && ((i >= 1 && str[i - 1] != '\\') || i == 0))
|
|
|
+ {
|
|
|
+ isSign = !isSign;
|
|
|
+ if (i == size - 1 && !isSign)
|
|
|
+ {
|
|
|
+ endindex = i;
|
|
|
+ it = RemoveHeadandTailChar(str.Substring(startindex, endindex - startindex + 1), '"');
|
|
|
+ ret.Add(it);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (i == size - 1)
|
|
|
+ {
|
|
|
+ endindex = i;
|
|
|
+ it = RemoveHeadandTailChar(str.Substring(startindex, endindex - startindex + 1), '"');
|
|
|
+ ret.Add(it);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ return ret.ToArray();
|
|
|
+ }
|
|
|
public static string RemoveHeadandTailChar(string str, char ch)
|
|
|
{
|
|
|
if (str.Length < 2)
|
|
|
@@ -111,7 +168,7 @@ public class FileHelper
|
|
|
if (File.Exists(path))
|
|
|
{
|
|
|
File.Delete(path);
|
|
|
- Debug.Log($"删除 [{path}]");
|
|
|
+ // Debug.Log($"删除 [{path}]");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -119,7 +176,7 @@ public class FileHelper
|
|
|
public static void WirteToFile(string filePath, byte[] data)
|
|
|
{
|
|
|
if (data == null || data.Length <= 0) return;
|
|
|
- Debug.Log($"保存到路径【{filePath}】 【长度 = {data.Length}】");
|
|
|
+ //Debug.Log($"保存到路径【{filePath}】 【长度 = {data.Length}】");
|
|
|
|
|
|
CreateDir(PathRemoveBack(filePath));
|
|
|
FileStream fs = new FileStream(filePath, FileMode.Create);
|
|
|
@@ -321,7 +378,7 @@ public class FileHelper
|
|
|
|
|
|
foreach (var item in files1)
|
|
|
{
|
|
|
- Debug.Log("===============File : " + item);
|
|
|
+ //Debug.Log("===============File : " + item);
|
|
|
byte[] fdatas = File.ReadAllBytes(dir + item);
|
|
|
|
|
|
WirteToFile($"{outDir}/{item}", fdatas);
|
|
|
@@ -338,7 +395,7 @@ public class FileHelper
|
|
|
|
|
|
foreach (var item in files1)
|
|
|
{
|
|
|
- Debug.Log("===============File : " + item);
|
|
|
+ //Debug.Log("===============File : " + item);
|
|
|
byte[] fdatas = File.ReadAllBytes(dir + item);
|
|
|
|
|
|
WirteToFile($"{outDir}/{item}", fdatas);
|