ソースを参照

优化获取用户名,新增获取目录文件夹大小(遍历累加)

yuzhengyang 7 年 前
コミット
28d449dcaa

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


+ 22 - 0
Azylee.Utils/Azylee.Core/IOUtils/DirUtils/DirTool.cs

@@ -6,6 +6,7 @@
 //************************************************************************
 //************************************************************************
 using Azylee.Core.DataUtils.CollectionUtils;
 using Azylee.Core.DataUtils.CollectionUtils;
 using Azylee.Core.DataUtils.StringUtils;
 using Azylee.Core.DataUtils.StringUtils;
+using Azylee.Core.IOUtils.FileUtils;
 using System;
 using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Diagnostics;
 using System.Diagnostics;
@@ -202,5 +203,26 @@ namespace Azylee.Core.IOUtils.DirUtils
             }
             }
             return sb.ToString();
             return sb.ToString();
         }
         }
+        public static long GetPathSize(string path)
+        {
+            long size = 0, _s = 0;
+            try
+            {
+                List<string> files = FileTool.GetAllFile(path);
+                if (ListTool.HasElements(files))
+                {
+                    foreach (var f in files)
+                    {
+                        if (File.Exists(f))
+                        {
+                            _s = FileTool.Size(f);
+                            if (_s >= 0) size += _s;
+                        }
+                    }
+                }
+            }
+            catch { }
+            return size;
+        }
     }
     }
 }
 }

+ 14 - 14
Azylee.Utils/Azylee.Core/WindowsUtils/InfoUtils/ComputerInfoTool.cs

@@ -321,25 +321,25 @@ namespace Azylee.Core.WindowsUtils.InfoUtils
         /// <returns></returns>
         /// <returns></returns>
         public static List<string> UserNames()
         public static List<string> UserNames()
         {
         {
-            int EntriesRead;
-            int TotalEntries;
-            int Resume;
-            IntPtr bufPtr;
             List<string> temp = new List<string>();
             List<string> temp = new List<string>();
-
-            NetUserEnum(null, 0, 2, out bufPtr, -1, out EntriesRead, out TotalEntries, out Resume);
-            if (EntriesRead > 0)
+            try
             {
             {
-                USER_INFO_0[] Users = new USER_INFO_0[EntriesRead];
-                IntPtr iter = bufPtr;
-                for (int i = 0; i < EntriesRead; i++)
+                IntPtr bufPtr;
+                NetUserEnum(null, 0, 2, out bufPtr, -1, out int EntriesRead, out int TotalEntries, out int Resume);
+                if (EntriesRead > 0)
                 {
                 {
-                    Users[i] = (USER_INFO_0)Marshal.PtrToStructure(iter, typeof(USER_INFO_0));
-                    iter = (IntPtr)((long)iter + Marshal.SizeOf(typeof(USER_INFO_0)));
-                    temp.Add(Users[i].Username);
+                    USER_INFO_0[] Users = new USER_INFO_0[EntriesRead];
+                    IntPtr iter = bufPtr;
+                    for (int i = 0; i < EntriesRead; i++)
+                    {
+                        Users[i] = (USER_INFO_0)Marshal.PtrToStructure(iter, typeof(USER_INFO_0));
+                        iter = (IntPtr)((long)iter + Marshal.SizeOf(typeof(USER_INFO_0)));
+                        temp.Add(Users[i].Username);
+                    }
+                    NetApiBufferFree(bufPtr);
                 }
                 }
-                NetApiBufferFree(bufPtr);
             }
             }
+            catch { }
             return temp;
             return temp;
         }
         }
         [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
         [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]

+ 8 - 1
Azylee.Utils/Azylee.Utils.sln

@@ -1,7 +1,7 @@
 
 
 Microsoft Visual Studio Solution File, Format Version 12.00
 Microsoft Visual Studio Solution File, Format Version 12.00
 # Visual Studio 15
 # Visual Studio 15
-VisualStudioVersion = 15.0.27428.2037
+VisualStudioVersion = 15.0.27004.2005
 MinimumVisualStudioVersion = 10.0.40219.1
 MinimumVisualStudioVersion = 10.0.40219.1
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azylee.Utils", "Azylee.Utils\Azylee.Utils.csproj", "{2D67AEF9-0238-49A5-A8C1-BE147A11C194}"
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azylee.Utils", "Azylee.Utils\Azylee.Utils.csproj", "{2D67AEF9-0238-49A5-A8C1-BE147A11C194}"
 EndProject
 EndProject
@@ -25,6 +25,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azylee.YeahWeb", "Azylee.Ye
 EndProject
 EndProject
 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{9351FC10-E8D0-41BB-A813-0B5B3EA90605}"
 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{9351FC10-E8D0-41BB-A813-0B5B3EA90605}"
 EndProject
 EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test.ProcessTool", "Tests\Test.ProcessTool\Test.ProcessTool.csproj", "{5FB93D25-8855-4A80-9E08-131BC728B7F4}"
+EndProject
 Global
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
 		Debug|Any CPU = Debug|Any CPU
@@ -67,6 +69,10 @@ Global
 		{CCF7A654-B442-4DB1-BB3B-0F8014C3237F}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{CCF7A654-B442-4DB1-BB3B-0F8014C3237F}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{CCF7A654-B442-4DB1-BB3B-0F8014C3237F}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{CCF7A654-B442-4DB1-BB3B-0F8014C3237F}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{CCF7A654-B442-4DB1-BB3B-0F8014C3237F}.Release|Any CPU.Build.0 = Release|Any CPU
 		{CCF7A654-B442-4DB1-BB3B-0F8014C3237F}.Release|Any CPU.Build.0 = Release|Any CPU
+		{5FB93D25-8855-4A80-9E08-131BC728B7F4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{5FB93D25-8855-4A80-9E08-131BC728B7F4}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{5FB93D25-8855-4A80-9E08-131BC728B7F4}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{5FB93D25-8855-4A80-9E08-131BC728B7F4}.Release|Any CPU.Build.0 = Release|Any CPU
 	EndGlobalSection
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE
 		HideSolutionNode = FALSE
@@ -80,6 +86,7 @@ Global
 		{0783D6B7-A0E9-4E3B-B2E8-C72D318F99CE} = {927325CD-24FD-4B85-A982-543D4F58A47C}
 		{0783D6B7-A0E9-4E3B-B2E8-C72D318F99CE} = {927325CD-24FD-4B85-A982-543D4F58A47C}
 		{D280C16F-FDE2-4647-BD76-3514F673426D} = {927325CD-24FD-4B85-A982-543D4F58A47C}
 		{D280C16F-FDE2-4647-BD76-3514F673426D} = {927325CD-24FD-4B85-A982-543D4F58A47C}
 		{CCF7A654-B442-4DB1-BB3B-0F8014C3237F} = {927325CD-24FD-4B85-A982-543D4F58A47C}
 		{CCF7A654-B442-4DB1-BB3B-0F8014C3237F} = {927325CD-24FD-4B85-A982-543D4F58A47C}
+		{5FB93D25-8855-4A80-9E08-131BC728B7F4} = {9351FC10-E8D0-41BB-A813-0B5B3EA90605}
 	EndGlobalSection
 	EndGlobalSection
 	GlobalSection(ExtensibilityGlobals) = postSolution
 	GlobalSection(ExtensibilityGlobals) = postSolution
 		SolutionGuid = {3A021A3E-4C98-47CD-B4E8-912E12611C2E}
 		SolutionGuid = {3A021A3E-4C98-47CD-B4E8-912E12611C2E}

+ 15 - 0
Azylee.Utils/Tests/Test.ProcessTool/Program.cs

@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Test.ProcessTool
+{
+    class Program
+    {
+        static void Main(string[] args)
+        {
+            Azylee.Core.ProcessUtils.ProcessTool.Start("CPAU.EXE","-u Zephyr -p 123456 ");
+        }
+    }
+}

+ 36 - 0
Azylee.Utils/Tests/Test.ProcessTool/Properties/AssemblyInfo.cs

@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// 有关程序集的一般信息由以下
+// 控制。更改这些特性值可修改
+// 与程序集关联的信息。
+[assembly: AssemblyTitle("Test.ProcessTool")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Test.ProcessTool")]
+[assembly: AssemblyCopyright("Copyright ©  2018")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// 将 ComVisible 设置为 false 会使此程序集中的类型
+//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
+//请将此类型的 ComVisible 特性设置为 true。
+[assembly: ComVisible(false)]
+
+// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
+[assembly: Guid("5fb93d25-8855-4a80-9e08-131bc728b7f4")]
+
+// 程序集的版本信息由下列四个值组成: 
+//
+//      主版本
+//      次版本
+//      生成号
+//      修订号
+//
+// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
+// 方法是按如下所示使用“*”: :
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

+ 53 - 0
Azylee.Utils/Tests/Test.ProcessTool/Test.ProcessTool.csproj

@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{5FB93D25-8855-4A80-9E08-131BC728B7F4}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <RootNamespace>Test.ProcessTool</RootNamespace>
+    <AssemblyName>Test.ProcessTool</AssemblyName>
+    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Program.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\..\Azylee.Core\Azylee.Core.csproj">
+      <Project>{88dc61fa-95f0-41b7-9d7d-ab0f3cbd169c}</Project>
+      <Name>Azylee.Core</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+</Project>

BIN
Fork.Net/.vs/Fork.Net/v15/Server/sqlite3/storage.ide


BIN
Fork.Net/.vs/Fork.Net/v15/sqlite3/storage.ide