Skip to content

Instantly share code, notes, and snippets.

@javierguerrero
Last active December 4, 2015 15:38
Show Gist options
  • Save javierguerrero/7cf03fc04209ad31ce60 to your computer and use it in GitHub Desktop.
Save javierguerrero/7cf03fc04209ad31ce60 to your computer and use it in GitHub Desktop.
How to remove trailing slash in C#
//Here is an example:
string fileName = "Test/";
fileName= fileName.TrimEnd(new[] { '/' });
//With this method you can also specify multiple characters so you may want to remove all slash or backslash using the array.
string fileName = "Test\\";
fileName= fileName.TrimEnd(new[] { '/', '\\' });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment