diff --git a/src/c#/GeneralUpdate.Client/MySample.cs b/src/c#/GeneralUpdate.Client/MySample.cs
index c84093fd9eaf1ad1ef572e689d96af0de5f5b9ae..6bc123e64c297fe24f696c491bd9e3878f5cc13c 100644
--- a/src/c#/GeneralUpdate.Client/MySample.cs
+++ b/src/c#/GeneralUpdate.Client/MySample.cs
@@ -12,6 +12,9 @@ using GeneralUpdate.Core.Domain.Enum;
using GeneralUpdate.Core.Events.CommonArgs;
using GeneralUpdate.Differential;
using System.IO;
+using GeneralUpdate.Core.Driver;
+using Microsoft.VisualBasic;
+using System.Diagnostics;
namespace GeneralUpdate.Client
{
@@ -231,5 +234,70 @@ namespace GeneralUpdate.Client
}
#endregion
+
+ #region 测试驱动功能
+
+ public void TestDrive()
+ {
+ var path1 = "D:\\packet\\source";
+ var path2 = "D:\\packet\\target";
+
+ var drivers = GetAllDriverDirectories(path1);
+
+ var information = new DriverInformation.Builder()
+ .SetInstallDirectory(path1)
+ .SetOutPutDirectory(path2)
+ .SetDriverNames(drivers)
+ .Build();
+
+ var processor = new DriverProcessor();
+ processor.AddCommand(new BackupDriverCommand(information));
+ processor.AddCommand(new DeleteDriverCommand(information));
+ processor.AddCommand(new InstallDriverCommand(information));
+ processor.ProcessCommands();
+ }
+
+ ///
+ /// Identifies all folders containing driver files in the specified directory and returns the directory collection.
+ ///
+ ///
+ ///
+ private List GetAllDriverDirectories(string path)
+ {
+ var driverDirectories = new HashSet();
+ try
+ {
+ foreach (string filePath in Directory.GetFiles(path))
+ {
+ if (IsDriverFile(filePath))
+ driverDirectories.Add(filePath);
+ }
+
+ foreach (string directory in Directory.GetDirectories(path))
+ {
+ driverDirectories.UnionWith(GetAllDriverDirectories(directory));
+ }
+ }
+ catch (UnauthorizedAccessException)
+ {
+ Trace.WriteLine("No access directory:" + path);
+ }
+ catch (PathTooLongException)
+ {
+ Trace.WriteLine("Path overlength:" + path);
+ }
+
+ return new List(driverDirectories);
+ }
+
+ ///
+ /// Match the driver installation boot file.
+ ///
+ ///
+ ///
+ private bool IsDriverFile(string filePath) =>
+ string.Equals(Path.GetExtension(filePath), ".inf", StringComparison.OrdinalIgnoreCase);
+
+ #endregion
}
}