Browse Source

添加txt读取字符格式选择,添加字符串数组查找工具

yuzhengyang 7 years ago
parent
commit
67732ef307

BIN
Azylee.Utils/.vs/Azylee.Utils/v15/Server/sqlite3/storage.ide


+ 1 - 0
Azylee.Utils/Azylee.Core/Azylee.Core.csproj

@@ -70,6 +70,7 @@
     <Compile Include="DataUtils\GuidUtils\GuidTool.cs" />
     <Compile Include="DataUtils\SerializeUtils\SerializeTool.cs" />
     <Compile Include="DataUtils\StringUtils\Str.cs" />
+    <Compile Include="DataUtils\StringUtils\StringArrayTool.cs" />
     <Compile Include="DataUtils\StringUtils\StringTool.cs" />
     <Compile Include="DataUtils\UnitConvertUtils\ByteConvertTool.cs" />
     <Compile Include="DelegateUtils\ProcessDelegateUtils\ProgressDelegate.cs" />

+ 19 - 0
Azylee.Utils/Azylee.Core/DataUtils/StringUtils/StringArrayTool.cs

@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Azylee.Core.DataUtils.StringUtils
+{
+    public static class StringArrayTool
+    {
+        public static int Find(string[] array, string s)
+        {
+            for (int i = 0; i < array.Length; i++)
+            {
+                if (array[i] == s) return i;
+            }
+            return -1;
+        }
+    }
+}

+ 14 - 0
Azylee.Utils/Azylee.Core/IOUtils/TxtUtils/TxtTool.cs

@@ -107,6 +107,20 @@ namespace Azylee.Core.IOUtils.TxtUtils
             }
             catch (Exception e) { }
         }
+        public static void ReadLine(string file,Encoding encoding, Action<int, string> action)
+        {
+            try
+            {
+                using (StreamReader sr = new StreamReader(file, encoding))
+                {
+                    string line;
+                    int number = 1;
+                    while ((line = sr.ReadLine()) != null)
+                        action.Invoke(number++, line);
+                }
+            }
+            catch (Exception e) { }
+        }
         public static long CountLine(string file, string[] filter)
         {
             long count = 0;