int index = sourceString.IndexOf(removeString);
string cleanPath = (index < 0)
? sourceString
: sourceString.Remove(index, removeString.Length);
More Related Contents:
- C# how to check if a string contains 3 times the same letters in a row [closed]
- How would you count occurrences of a string (actually a char) within a string?
- How to convert UTF-8 byte[] to string
- How do I parse a string with a decimal point to a double?
- Splitting a string into chunks of a certain size
- Color different parts of a RichTextBox string
- How to access random item in list?
- How do I replace multiple spaces with a single space in C#?
- Difference between string and StringBuilder in C#
- How to parse a string into a nullable int
- How to convert DateTime to/from specific string format (both ways, e.g. given Format is “yyyyMMdd”)?
- String interning in .Net Framework – What are the benefits and when to use interning
- Converting string expression to Integer Value using C# [duplicate]
- Alternative to multiple String.Replaces [duplicate]
- How to extend C# built-in types, like String?
- Removing hidden characters from within strings
- Regex : how to get words from a string (C#)
- Two different “strings” are the same object instance?
- Convert string to hex-string in C#
- Using variables inside strings
- Obtain SHA-256 string of a string
- Remove file extension from a file name string
- What method in the String class returns only the first N characters?
- split a string on newlines in .NET
- Does StringBuilder use more memory than String concatenation?
- Why is the default value of the string type null instead of an empty string?
- Hashing a string with SHA256
- How can I check if a string contains a character in C#?
- Parsing through Arabic / RTL text from left to right
- How to get the first five character of a String