.net - Selecting a specific part of a string C# -


i trying create new string, removes characters existing string e.g.

string path = "c:\test.txt" 

so string "pathminus" take out "c:\" e.g.

string pathminus = "test.txt" 

the string class offers sorts of ways this.

if want change "c:\test.txt" "test.txt" removing first 3 characters:

path.substring(3); 

if want remove "c:\" anywhere in string:

path.replace("c:\", ""); 

or if want filename, regardless of how long path is:

path.getfilename(path); 

depending on intentions, there many ways it. prefer using static class path.


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -