dotnet / dotnet/dotnet-api-docs

Path.GetFileName behavior change on .NET Core

Open
#2,644 1 comment 0 reactions 0 assignees View on GitHub
area-System.IO Pri1 Pri3
Dominant language
C#
Stars
949
Forks
1.7k
Avg merge
3d 27m
Merged PRs (30d)
49

Description

In .NET Core we consider `Path.GetPathRoot()` when finding the filename. The concept of `Path.VolumeSeparatorChar` is only relevant on Windows 9x machines. So:

**.NET Framework**
```
The characters after the last directory separator character in path. If the last character of path is a directory or volume separator character, this method returns Empty.
```

**.NET Core**
```
The characters after the last directory separator character after the path root (see Path.GetPathRoot) in path. If the path only contains a root, returns empty.
```

We should add to `Path.VolumeSeparatorChar` that we recommend not using it directly as it is a Win9x anachronism. Use `Path.GetPathRoot` to determine path roots.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.