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
  1. Home
  2. Web Development
  3. ASP.NET
  4. string.replace

string.replace

Scheduled Pinned Locked Moved ASP.NET
helptutorial
9 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.
  • S Offline
    S Offline
    Sebastian T Xavier
    wrote on last edited by
    #1

    Hi all, I need your help in replace function......... Please look the code below..... string File; File = "C:\\Documents and Settings\\sxavier\\Desktop\\prasobh.doc"; string strFileName = File; I would like to replace \\ with \... I have tried the line below , but will not work.... strFileName = strFileName.Replace("\\", "\"); Please guide me .... Thanks in advance Sebastian

    N V S I 4 Replies Last reply
    0
    • S Sebastian T Xavier

      Hi all, I need your help in replace function......... Please look the code below..... string File; File = "C:\\Documents and Settings\\sxavier\\Desktop\\prasobh.doc"; string strFileName = File; I would like to replace \\ with \... I have tried the line below , but will not work.... strFileName = strFileName.Replace("\\", "\"); Please guide me .... Thanks in advance Sebastian

      N Offline
      N Offline
      N a v a n e e t h
      wrote on last edited by
      #2

      Sebastian T Xavier wrote:

      strFileName = strFileName.Replace("\\", "\");

      strFileName = strFileName.Replace("\\", @"\");


      My Website | Ask smart questions

      S 1 Reply Last reply
      0
      • S Sebastian T Xavier

        Hi all, I need your help in replace function......... Please look the code below..... string File; File = "C:\\Documents and Settings\\sxavier\\Desktop\\prasobh.doc"; string strFileName = File; I would like to replace \\ with \... I have tried the line below , but will not work.... strFileName = strFileName.Replace("\\", "\"); Please guide me .... Thanks in advance Sebastian

        V Offline
        V Offline
        Vasudevan Deepak Kumar
        wrote on last edited by
        #3

        Sebastian T Xavier wrote:

        strFileName = strFileName.Replace("\\", "\");

        It breaks "Build" with the error "Newline in constant".

        Sebastian T Xavier wrote:

        strFileName = strFileName.Replace("\\", "\");

        strFileName = strFileName.Replace("\\", "\"); strFileName = strFileName.Replace(@"\\", @"\");

        Vasudevan Deepak Kumar Personal Homepage Tech Gossips

        S 1 Reply Last reply
        0
        • S Sebastian T Xavier

          Hi all, I need your help in replace function......... Please look the code below..... string File; File = "C:\\Documents and Settings\\sxavier\\Desktop\\prasobh.doc"; string strFileName = File; I would like to replace \\ with \... I have tried the line below , but will not work.... strFileName = strFileName.Replace("\\", "\"); Please guide me .... Thanks in advance Sebastian

          S Offline
          S Offline
          sathesh pandian
          wrote on last edited by
          #4

          hi, try to use / instead of \ otherwise use @"\". \ is a new line character in C# and your code will work only in vb.net. So it is better to avoid it.

          All The Best Sathesh Pandian

          S 1 Reply Last reply
          0
          • S Sebastian T Xavier

            Hi all, I need your help in replace function......... Please look the code below..... string File; File = "C:\\Documents and Settings\\sxavier\\Desktop\\prasobh.doc"; string strFileName = File; I would like to replace \\ with \... I have tried the line below , but will not work.... strFileName = strFileName.Replace("\\", "\"); Please guide me .... Thanks in advance Sebastian

            I Offline
            I Offline
            Imran Khan Pathan
            wrote on last edited by
            #5

            try with this Replace("\\", @"\"); Best Regard Pathan

            GOD HELP THOSE WHO HELP THEMSELVES

            S 1 Reply Last reply
            0
            • N N a v a n e e t h

              Sebastian T Xavier wrote:

              strFileName = strFileName.Replace("\\", "\");

              strFileName = strFileName.Replace("\\", @"\");


              My Website | Ask smart questions

              S Offline
              S Offline
              Sebastian T Xavier
              wrote on last edited by
              #6

              Thank you Navneet,it worked sebastian

              1 Reply Last reply
              0
              • V Vasudevan Deepak Kumar

                Sebastian T Xavier wrote:

                strFileName = strFileName.Replace("\\", "\");

                It breaks "Build" with the error "Newline in constant".

                Sebastian T Xavier wrote:

                strFileName = strFileName.Replace("\\", "\");

                strFileName = strFileName.Replace("\\", "\"); strFileName = strFileName.Replace(@"\\", @"\");

                Vasudevan Deepak Kumar Personal Homepage Tech Gossips

                S Offline
                S Offline
                Sebastian T Xavier
                wrote on last edited by
                #7

                Thank you........... sebastian

                1 Reply Last reply
                0
                • S sathesh pandian

                  hi, try to use / instead of \ otherwise use @"\". \ is a new line character in C# and your code will work only in vb.net. So it is better to avoid it.

                  All The Best Sathesh Pandian

                  S Offline
                  S Offline
                  Sebastian T Xavier
                  wrote on last edited by
                  #8

                  Thank you............. sebastian

                  1 Reply Last reply
                  0
                  • I Imran Khan Pathan

                    try with this Replace("\\", @"\"); Best Regard Pathan

                    GOD HELP THOSE WHO HELP THEMSELVES

                    S Offline
                    S Offline
                    Sebastian T Xavier
                    wrote on last edited by
                    #9

                    Thank you........... Sebastian

                    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