Skip to content

System.IO.Directory.Move fails between two mounts on Linux #31149

Open
@hsorbo

Description

@hsorbo

On Linux/netcore3 System.IO.Directory.Move throws System.IO.IOException: Invalid cross-device link when trying to move a folder between two mounts/disks in Linux.

System.IO.Directory.Move("/tmp/foo","/tmp/baz"); //works
System.IO.Directory.Move("/mnt/notsamedisk/foo","/tmp/baz"); //throws

Unhandled exception. System.IO.IOException: Invalid cross-device link
   at System.IO.FileSystem.MoveDirectory(String sourceFullPath, String destFullPath)
   at System.IO.Directory.Move(String sourceDirName, String destDirName)
   at tmp.Program.Main(String[] args) in /home/easysky/tmp/Program.cs:line 9
using System;

namespace tmp
{
    class Program
    {
        static void Main(string[] args)
        {
            System.IO.Directory.Move("/datadrive/tmp/foo","/tmp/foo");
        }
    }
}

uname -a Linux Test 5.0.0-1018-azure dotnet/corefx#19~18.04.1-Ubuntu SMP Wed Aug 21 05:13:05 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

dotnet --version
3.0.100

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions