@@ -17,7 +17,7 @@ internal class PacketViewModel : ViewModeBase
1717 {
1818 #region Private Members
1919
20- private string sourcePath , targetPath , patchPath , infoMessage , url , packetName ;
20+ private string sourcePath , targetPath , patchPath , infoMessage , url , packetName , driverDir ;
2121 private List < string > _formats , _encodings , _appTypes ;
2222 private string _currentFormat , _currentEncoding , _currentAppType , _currentVersion , _currentClientAppKey ;
2323 private bool isPublish ;
@@ -49,6 +49,7 @@ internal PacketViewModel()
4949 public bool IsPublish { get => isPublish ; set => SetProperty ( ref isPublish , value ) ; }
5050 public string Url { get => url ; set => SetProperty ( ref url , value ) ; }
5151 public string PacketName { get => packetName ; set => SetProperty ( ref packetName , value ) ; }
52+ public string DriverDir { get => packetName ; set => SetProperty ( ref driverDir , value ) ; }
5253
5354 public AsyncRelayCommand < string > SelectFolderCommand
5455 {
@@ -148,7 +149,7 @@ private async Task SelectFolderAction(string value)
148149 var openFileDialog = new OpenFileDialog ( ) ;
149150 openFileDialog . InitialDirectory = @"D:\" ;
150151 openFileDialog . Filter = "All files (*.*)|*.*" ;
151- if ( ! openFileDialog . ShowDialog ( ) . Value )
152+ if ( openFileDialog . ShowDialog ( ) == false )
152153 {
153154 await ShowMessage ( "Pick options" , "No results were selected !" ) ;
154155 return ;
@@ -168,6 +169,10 @@ private async Task SelectFolderAction(string value)
168169 case "Patch" :
169170 PatchPath = selectedFilePath ;
170171 break ;
172+
173+ case "Driver" :
174+ DriverDir = selectedFilePath ;
175+ break ;
171176 }
172177 }
173178
@@ -190,6 +195,7 @@ private async Task BuildPacketCallback()
190195
191196 try
192197 {
198+ CopyDirectory ( DriverDir , TargetPath ) ;
193199 await DifferentialCore . Instance . Clean ( SourcePath , TargetPath , PatchPath , ( sender , args ) => { } ,
194200 String2OperationType ( CurrentFormat ) , String2Encoding ( CurrentEncoding ) , PacketName ) ;
195201 if ( IsPublish )
@@ -315,13 +321,34 @@ await Application.Current.Dispatcher.BeginInvoke(new Action(() =>
315321 } ) ) ;
316322 }
317323
318-
319324 /// <summary>
320- /// Check whether the directory contains driver files .
325+ /// Copy all folders containing drivers in the root directory .
321326 /// </summary>
322- /// <param name="subPath"></param>
323- /// <returns></returns>
324- public bool IsDriver ( string subPath ) => Directory . EnumerateFiles ( subPath , "*.inf" ) . Any ( ) ;
327+ /// <param name="sourceDir"></param>
328+ /// <param name="targetDir"></param>
329+ private void CopyDirectory ( string sourceDir , string targetDir )
330+ {
331+ if ( string . IsNullOrWhiteSpace ( sourceDir ) || string . IsNullOrEmpty ( targetDir ) )
332+ return ;
333+
334+ if ( ! Directory . Exists ( targetDir ) )
335+ Directory . CreateDirectory ( targetDir ) ;
336+
337+ foreach ( var file in Directory . GetFiles ( sourceDir ) )
338+ {
339+ if ( Path . GetExtension ( file ) == ".inf" )
340+ {
341+ var targetPath = Path . Combine ( targetDir , Path . GetFileName ( file ) ) ;
342+ File . Copy ( file , targetPath , true ) ;
343+ }
344+ }
345+
346+ foreach ( var directory in Directory . GetDirectories ( sourceDir ) )
347+ {
348+ var targetPath = Path . Combine ( targetDir , Path . GetFileName ( directory ) ) ;
349+ CopyDirectory ( directory , targetPath ) ;
350+ }
351+ }
325352
326353 #endregion Private Methods
327354 }
0 commit comments