Skip to content

MoveFilesAndFolders - "Cannot delete source Directory" error #151

@RFBomb

Description

@RFBomb

My project is taking ALL files and folders EXCEPT 2 folders from the Root of a USB stick, and stuffing them into a backup folder on the root of the USB.

For example:

Source: E:
Destination: $"E:\USB_BACKUP\{DateTime.Now.ToString("yyyy-MM-dd_hh_m_tt")};"

E:\FolderIgnore1
E:\USB_BACKUP
E:\SomeOtherFolderWithFiles
E:\SomeFile

turns into

E:\FolderIgnore1
E:\USB_BACKUP
E:\USB_BACKUP\CurrentDateTimeFolderName
E:\USB_BACKUP\CurrentDateTimeFolderName\SomeOtherFolderWithFiles
E:\USB_BACKUP\CurrentDateTimeFolderName\SomeFile

All that works, but RoboCopy reports an error that it cannot delete the source directory, which is typically done during the 'MoveFilesAndFolders'. I know WHY its erroring - It can't delete the source from the drive because the source IS the root of the drive.

Any idea how to prevent that error being generated?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions