Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. c# string split functions

c# string split functions

Scheduled Pinned Locked Moved C#
csharpquestionannouncement
6 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AndieDu
    wrote on last edited by
    #1

    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

    C realJSOPR R 3 Replies Last reply
    0
    • A AndieDu

      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

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Path.GetFileNameWithoutExtension(yourstring)

      Christian Graus No longer a Microsoft MVP, but still happy to answer your questions.

      A P 2 Replies Last reply
      0
      • C Christian Graus

        Path.GetFileNameWithoutExtension(yourstring)

        Christian Graus No longer a Microsoft MVP, but still happy to answer your questions.

        A Offline
        A Offline
        AndieDu
        wrote on last edited by
        #3

        Thanks a lot Christian, you are the legend. cheers

        1 Reply Last reply
        0
        • A AndieDu

          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

          realJSOPR Offline
          realJSOPR Offline
          realJSOP
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          • C Christian Graus

            Path.GetFileNameWithoutExtension(yourstring)

            Christian Graus No longer a Microsoft MVP, but still happy to answer your questions.

            P Offline
            P Offline
            PIEBALDconsult
            wrote on last edited by
            #5

            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.

            1 Reply Last reply
            0
            • A AndieDu

              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

              R Offline
              R Offline
              Ravi Kumar Tyagi
              wrote on last edited by
              #6

              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.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups