KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I need to extract the path info using Path.GetFileName() , and this function doesn't work when the last character of the input string is DirectorySeparatorChar('/' or '\'). I came up with this code, but it's too lengthy. Is there a better way to go? string lastCharString = fullPath.Substring (fullPath.Length-1); char lastChar = lastCharString[0]; if (lastChar == Path.DirectorySeparatorChar) { fullPath = fullPath.Substring(0, fullPath.Length-1); }
Tags (comma-separated)
Save Edits
Cancel