0

I can't move files from disk C: to D:

From C: to C: is working, but only this it's not enough.

Exception Message: The source path and the destination path must have the same root. The drive will not work between volumes.

I trying this

public class Tests
{

    public static void MoveFiles(string tarjet, string destiny)
    {
        var files = new DirectoryInfo(tarjet).GetFiles();
        var directories = new DirectoryInfo(tarjet).GetDirectories();

        foreach (var d in directories)
        {
            Directory.Move(d.FullName, Path.Combine(destiny, d.Name));
        }

        foreach (var f in files)
        {
            File.Move(f.FullName, Path.Combine(destiny, f.Name));
        }
    }
}
  • Please try to find a *minimal* code that reproduces the problem. And provide compilable code, please. That's called a [mcve]. In your case, that should probably be less than 10 lines of code. – Thomas Weller Jan 10 '17 at 12:31
  • Before c# dos supported rename across devices (move) I'm just saying. – danny117 Jan 10 '17 at 12:33
  • @danny117: before what or when? – Thomas Weller Jan 10 '17 at 12:41
  • I've changed the code, considering your criticisms. – filipecampos Jan 10 '17 at 12:47
  • 1
    @danny Windows does support it, the C# part is irrelevant. There are though some .NET classes that don't fully support this. That's probably because a move across partitions or devices (i.e. with a **physical separation**) is an abstraction of an atomic copy+delete, which may be hard to implement cross-platform. – CodeCaster Jan 10 '17 at 12:49

0 Answers0