user3794028
user3794028

Reputation: 11

Move directory using C#

I'm trying to cut a folder. I've tried directoy.move(string source,string dest) & directoryinfo.moveto(dest) but in both case an exception was thrown "Source and destination path must have identical roots. Move will not work across volume".

Upvotes: 1

Views: 571

Answers (1)

James Hunt
James Hunt

Reputation: 2528

You cannot move files and folders across different volumes with Directory.Move. You have to create the directory at the destination, recursively copy the files across then, on success, delete the files at the source or, as Tim suggested in the comments below, recursively create the directory structure then move the files across with File.Move.

Upvotes: 2

Related Questions