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. readin txt file

readin txt file

Scheduled Pinned Locked Moved C#
7 Posts 2 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.
  • I Offline
    I Offline
    icanmakeiteasy
    wrote on last edited by
    #1

    Hi friends, i have a txt file containing email id's like test.txt asdf@gmail.com qwer@gmail.com zxcv@gmail.com when user imports test.txt file i want to get the all email id's by comma seperated value... using c# asdf@gmail.com,qwer@gmail.com,zxcv@gmail.com .... like this how can i?? help me plzzz...

    icanmakeiteasy

    L 1 Reply Last reply
    0
    • I icanmakeiteasy

      Hi friends, i have a txt file containing email id's like test.txt asdf@gmail.com qwer@gmail.com zxcv@gmail.com when user imports test.txt file i want to get the all email id's by comma seperated value... using c# asdf@gmail.com,qwer@gmail.com,zxcv@gmail.com .... like this how can i?? help me plzzz...

      icanmakeiteasy

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      string[] emails = File.ReadAllLines(@"test.txt"); StringBuilder stringBuilder = new StringBuilder(); foreach(string email in emails) { stringBuilder.Append(email); stringBuilder.Append(","); } File.WriteAllText(@"newtext.txt", stringBuilder.ToString());

      I 1 Reply Last reply
      0
      • L Lost User

        string[] emails = File.ReadAllLines(@"test.txt"); StringBuilder stringBuilder = new StringBuilder(); foreach(string email in emails) { stringBuilder.Append(email); stringBuilder.Append(","); } File.WriteAllText(@"newtext.txt", stringBuilder.ToString());

        I Offline
        I Offline
        icanmakeiteasy
        wrote on last edited by
        #3

        thank you... its working and if the mails are separated by space like this test.txt asdf@gmail.com qwer@gmail.com zxcv@gmail.com now can i get them by comma separated mails... thank you

        icanmakeiteasy

        L 1 Reply Last reply
        0
        • I icanmakeiteasy

          thank you... its working and if the mails are separated by space like this test.txt asdf@gmail.com qwer@gmail.com zxcv@gmail.com now can i get them by comma separated mails... thank you

          icanmakeiteasy

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          just change "," with " ".

          I 1 Reply Last reply
          0
          • L Lost User

            just change "," with " ".

            I Offline
            I Offline
            icanmakeiteasy
            wrote on last edited by
            #5

            thanks... my input file is test.txt asdf@gmail.com qwer@gmail.com zxcv@gmail.com now i want like this asdf@gmail.com,qwer@gmail.com,zxcv@gmail.com ???

            icanmakeiteasy

            L 1 Reply Last reply
            0
            • I icanmakeiteasy

              thanks... my input file is test.txt asdf@gmail.com qwer@gmail.com zxcv@gmail.com now i want like this asdf@gmail.com,qwer@gmail.com,zxcv@gmail.com ???

              icanmakeiteasy

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              string alltexts = File.ReadAllText(@"test.txt"); string[] emails = alltexts.Split(' '); StringBuilder stringBuilder = new StringBuilder(); foreach (string email in emails) { stringBuilder.Append(email); stringBuilder.Append(","); } File.WriteAllText(@"newtext.txt", stringBuilder.ToString());

              I 1 Reply Last reply
              0
              • L Lost User

                string alltexts = File.ReadAllText(@"test.txt"); string[] emails = alltexts.Split(' '); StringBuilder stringBuilder = new StringBuilder(); foreach (string email in emails) { stringBuilder.Append(email); stringBuilder.Append(","); } File.WriteAllText(@"newtext.txt", stringBuilder.ToString());

                I Offline
                I Offline
                icanmakeiteasy
                wrote on last edited by
                #7

                wow that's working.. thank you.....

                icanmakeiteasy

                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