Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Path.GetDirectoryName dose not work on linux #29470

Closed
HassanHashemi opened this issue May 7, 2019 · 2 comments
Closed

Path.GetDirectoryName dose not work on linux #29470

HassanHashemi opened this issue May 7, 2019 · 2 comments
Milestone

Comments

@HassanHashemi
Copy link

Consider this code snippet:

 var path = "zj\\qj\\zjqjyed9vclmuljlky2nxv-6v-Thumbs\\zjqjyed9vclmuljlky2nxv-6v01.jpg";
 var directory = Path.GetDirectoryName(path);
 Console.WriteLine(directory);

On Windows Path.GetDirectoryName(path) returns:

   zj\qj\zjqjyed9vclmuljlky2nxv-6v-Thumbs

Which is expected while on Linux returns empty.

dotnet --version:
.Net core 2.2.104

Windows environment:
Win10

Linux:
Ubuntu 18.04 LTS

@Wraith2
Copy link
Contributor

Wraith2 commented May 7, 2019

On windows \ is the standard and / is the alt directory separator char. On linux / is the only separator char and \ is a valid filename character. So linux interprets the path you give it according to the local rules and finds no directory separator char to split on, this is behaving as expected.

@HassanHashemi
Copy link
Author

Sorry, that was a terrible mistake.

@msftgits msftgits transferred this issue from dotnet/corefx Feb 1, 2020
@msftgits msftgits added this to the 3.0 milestone Feb 1, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants