I am trying to create a new string, which removes certain characters from an existing string e.g.
string path = "C:\test.txt"
so string “pathminus” will take out the “C:\” e.g.
string pathminus = "test.txt"
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The string class offers all sorts of ways to do this.
If you want to change “C:\test.txt” to “test.txt” by removing the first three characters:
If you want to remove “C:\” from anywhere in the string:
Or if you specifically want the filename, regardless of how long the path is:
Depending on your intentions, there are many ways to do it. I prefer using the static class
Path.