© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
8 replies
Pokey

❔ ✅ Parsing path into parts with varying separators?

The traditional way to do this would be

string myPath = "C:\\Users\\Me\\Desktop";
string[] myPathParts = myPath.Split(Path.DirectorySeparatorChar);
string myPath = "C:\\Users\\Me\\Desktop";
string[] myPathParts = myPath.Split(Path.DirectorySeparatorChar);


But what if the path uses / instead of \ because as far as I am aware Windows will understand this, but that wouldn't be the
DirectorySeparatorChar
DirectorySeparatorChar
?

Thanks!
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Parsing XML directly into serializable object?
C#CC# / help
2y ago
Parsing a binary file into a byte array
C#CC# / help
3y ago
Parsing an arbitrary file path as a Uri or similar
C#CC# / help
3y ago