Colon character in file/directory on NFS share causing exception
Colon character in file/directory on NFS share causing exception
Some characters are illegal on Windows file system but are perfectly fine on third party file systems. Windows Explorer and CMD prompt have no problems with directory called "Foo:bar", but .NET Core (and .NET 4) generates System.NotSupportedException: The given path's format is not supported.
General
Create a share to a Linux machine or NAS device (tested with Synology NAS and NFS, on Windows Server install Client for NFS)
Map that share to x:
In the share create a folder Test. Inside the folder Test create a folder 'Foo:bar', note that this is easiest done natively on the device, either web interface, putty or FTP.
Create a .NET Core console app.
var info = new DirectoryInfo("x:\test") var dirs = info.GetDirectories(); //dirs contains now one entry of "Foo:bar" var name = dirs[0].Name // <== already wrong, name is reported as "bar" dirs = dirs[0].GetDirectories(); // <== NotSupportedException
In code there is likely a check whether the colon is used anywhere else besides for drive letter and generates an exception. Better approach would be that creating new folders and files keeps this check, but for existing entries it should just work just like in File Explorer and CMD prompt, where you can browse inside the directory without any issues.
Just to let you know, when using SMB shares the Synology exposes such folder names as something with an entirely different name (like "FP8AMI~K"), so this can only be tested properly on a Windows Server with Client for NFS
Issue moved to dotnet/corefx #26359 via ZenHub