@@ -527,9 +527,10 @@ public async Task oneItemDeleteAsync(string dbName, Syncfusion.Blazor.FileManage
527527 {
528528 if ( ! item . IsFile )
529529 {
530- var result = await copyAllDirectoryFiles ( dbName , item . Id , args . TargetData , args . TargetPath + item . Name + "/" ) ;
530+ // Pass args.IsCopy to handle internal files correctly (delete originals when moving)
531+ var result = await copyAllDirectoryFiles ( dbName , item . Id , args . TargetData , args . TargetPath + item . Name + "/" , args . IsCopy ) ;
531532 lista . Add ( result . toFileManagerContentInCopy ( ) ) ;
532-
533+ // Note: copyAllDirectoryFiles now handles deletion of the folder when IsCopy=false
533534 }
534535 else
535536 {
@@ -539,7 +540,6 @@ public async Task oneItemDeleteAsync(string dbName, Syncfusion.Blazor.FileManage
539540 {
540541 await _db . deleteEntry ( dbName , item . Id ) ;
541542 }
542-
543543 }
544544 await _db . addBytesToFolder ( dbName , item . ParentId , item . Size ) ;
545545 }
@@ -573,12 +573,10 @@ public async Task oneItemDeleteAsync(string dbName, Syncfusion.Blazor.FileManage
573573 {
574574 if ( ! item . IsFile )
575575 {
576- var result = await copyAllDirectoryFiles ( dbName , item . Id , targetData , targetPath + item . Name + "/" ) ;
576+ // Pass isCopy to handle internal files correctly (delete originals when moving)
577+ var result = await copyAllDirectoryFiles ( dbName , item . Id , targetData , targetPath + item . Name + "/" , isCopy ) ;
577578 lista . Add ( result . toFileManagerContentInCopy ( ) ) ;
578- if ( ! isCopy )
579- {
580- await _db . deleteEntry ( dbName , item . Id ) ;
581- }
579+ // Note: copyAllDirectoryFiles now handles deletion of the folder when isCopy=false
582580 }
583581 else
584582 {
@@ -626,11 +624,9 @@ private async Task<BsonFileManagerModel> copyAllDirectoryFiles(string dbName, st
626624 }
627625 else
628626 {
629- await copyAllDirectoryFiles ( dbName , file . Id , result . toFileManagerContent ( ) , targetPath + file . Name + "/" ) ;
630- if ( ! isCopy )
631- {
632- await _db . deleteEntry ( dbName , file . Id ) ;
633- }
627+ // Pass isCopy to recursive call to handle nested folders correctly
628+ await copyAllDirectoryFiles ( dbName , file . Id , result . toFileManagerContent ( ) , targetPath + file . Name + "/" , isCopy ) ;
629+ // Note: recursive call handles deletion when isCopy=false, no need to delete here
634630 }
635631 }
636632 if ( ! isCopy )
0 commit comments