@@ -135,8 +135,10 @@ public override void SyncSourceToDest()
135135 throw new ArgumentNullException ( "Credentials are not set - cannot connect to share" ) ;
136136 }
137137
138+ Directory . CreateDirectory ( jobOptions . DestinationPath ) ;
139+ foreach ( var subfolder in jobOptions . Subfolders )
140+ Directory . CreateDirectory ( Path . Combine ( jobOptions . DestinationPath , subfolder ) ) ;
138141 DirectoryInfo _di = new DirectoryInfo ( jobOptions . DestinationPath ) ;
139-
140142 foreach ( var dir in JobOptions . Subfolders . Count > 0 ? _di . GetDirectories ( ) : new [ ] { _di } )
141143 {
142144 if ( JobOptions . Subfolders . Count > 0 && ! JobOptions . Subfolders . Select ( x => x . ToLower ( ) ) . Contains ( dir . Name . ToLower ( ) ) )
@@ -147,7 +149,7 @@ public override void SyncSourceToDest()
147149 searchPattern : JobOptions . SearchPattern ,
148150 searchOption : JobOptions . Recursive ? SearchOption . AllDirectories : SearchOption . TopDirectoryOnly ) ;
149151
150- var remoteFiles = ListFiles ( SourcePath , true ) ;
152+ var remoteFiles = ListFiles ( Path . Combine ( SourcePath , dir . Name ) , JobOptions . Recursive ) ;
151153 if ( jobOptions . SyncDeleted )
152154 {
153155 foreach ( var file in remoteFiles )
@@ -318,6 +320,8 @@ public void WriteFile(string localFilePath, string remoteFilePath)
318320 status = fileStore . CloseFile ( fileHandle ) ;
319321 }
320322 localFileStream . Dispose ( ) ;
323+ var fileInfo = new FileInfo ( localFilePath ) ;
324+ SetFileAttributes ( remoteFilePath , fileInfo . LastWriteTime , fileInfo . CreationTime , fileInfo . LastWriteTime , fileInfo . LastAccessTime ) ;
321325
322326 }
323327 void DeleteFile ( string filePath )
0 commit comments