c# string split functions
-
Hi All, i have these strings: C:\CCCRM\CCCRM\bin\release\cccrmNeeded.dll. how can i take the "cccrm_Needed" out of this string. i have this code here: char[] delimiterChar = { ':', '\\', '.' }; string[] module = file.Split(delimiterChar); foreach (string str1 in module) { // To grab the needed string, which is "cccrm_Needed" } Many thanks Andie
-
Hi All, i have these strings: C:\CCCRM\CCCRM\bin\release\cccrmNeeded.dll. how can i take the "cccrm_Needed" out of this string. i have this code here: char[] delimiterChar = { ':', '\\', '.' }; string[] module = file.Split(delimiterChar); foreach (string str1 in module) { // To grab the needed string, which is "cccrm_Needed" } Many thanks Andie
Path.GetFileNameWithoutExtension(yourstring)
Christian Graus No longer a Microsoft MVP, but still happy to answer your questions.
-
Path.GetFileNameWithoutExtension(yourstring)
Christian Graus No longer a Microsoft MVP, but still happy to answer your questions.
-
Hi All, i have these strings: C:\CCCRM\CCCRM\bin\release\cccrmNeeded.dll. how can i take the "cccrm_Needed" out of this string. i have this code here: char[] delimiterChar = { ':', '\\', '.' }; string[] module = file.Split(delimiterChar); foreach (string str1 in module) { // To grab the needed string, which is "cccrm_Needed" } Many thanks Andie
string myPathString = "C:\CCCRM\CCCRM\bin\release\cccrmNeeded.dll";
string fileName = System.IO.Path.GetFileName(myPathString);"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001 -
Path.GetFileNameWithoutExtension(yourstring)
Christian Graus No longer a Microsoft MVP, but still happy to answer your questions.
I knew there had to be a better way and it would present itself eventually. I've just never had need of the Path class before (or didn't know I did). The FileInfo class really ought to have this member as well.
-
Hi All, i have these strings: C:\CCCRM\CCCRM\bin\release\cccrmNeeded.dll. how can i take the "cccrm_Needed" out of this string. i have this code here: char[] delimiterChar = { ':', '\\', '.' }; string[] module = file.Split(delimiterChar); foreach (string str1 in module) { // To grab the needed string, which is "cccrm_Needed" } Many thanks Andie
instead for using the split function you can directly use the Path class of IO sample code is System.IO.Path.GetFileNameWithoutExtension (@"C:\CCCRM\CCCRM\bin\release\cccrmNeeded.dll"); and this will return the cccrmNeeded.