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. General Programming
  3. C#
  4. Cant copy a complete text file

Cant copy a complete text file

Scheduled Pinned Locked Moved C#
jsonhelpquestion
8 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
    ayandelhi
    wrote on last edited by
    #1

    hi!! m back... this time i thinks its a very basic problem... i'm trying to copy all the contents of a file(a txt file of 700 lines) when i write it in another file, it writes 75% of text.... it leaves the rest... y??? i dont understand... i'm using stream reader n writer... is it the way to do it..

    R L L K 4 Replies Last reply
    0
    • A ayandelhi

      hi!! m back... this time i thinks its a very basic problem... i'm trying to copy all the contents of a file(a txt file of 700 lines) when i write it in another file, it writes 75% of text.... it leaves the rest... y??? i dont understand... i'm using stream reader n writer... is it the way to do it..

      R Offline
      R Offline
      riced
      wrote on last edited by
      #2

      ayandelhi wrote:

      i dont understand...

      Without seeing any code I doubt anyone else will either. :-D Why not just use File.Copy()? (If there was some code it might explain why you cannot use it. :) )

      Regards David R --------------------------------------------------------------- "Every program eventually becomes rococo, and then rubble." - Alan Perlis The only valid measurement of code quality: WTFs/minute.

      A 1 Reply Last reply
      0
      • A ayandelhi

        hi!! m back... this time i thinks its a very basic problem... i'm trying to copy all the contents of a file(a txt file of 700 lines) when i write it in another file, it writes 75% of text.... it leaves the rest... y??? i dont understand... i'm using stream reader n writer... is it the way to do it..

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

        Is the problem that you are missing the <CR><LF> characters from your output file and are you using ReadLine()[^] to read your input file? If so, note that the line end characters <CR> and/or <LF> do not get copied into your input buffer.

        It's time for a new signature.

        1 Reply Last reply
        0
        • R riced

          ayandelhi wrote:

          i dont understand...

          Without seeing any code I doubt anyone else will either. :-D Why not just use File.Copy()? (If there was some code it might explain why you cannot use it. :) )

          Regards David R --------------------------------------------------------------- "Every program eventually becomes rococo, and then rubble." - Alan Perlis The only valid measurement of code quality: WTFs/minute.

          A Offline
          A Offline
          ayandelhi
          wrote on last edited by
          #4

          static string file=""; static string line=""; static void Main(string[] args) { StreamReader sr=new StreamReader("d:\\file1.txt"); StreamWriter sw=new StreamWriter("D:\\file2.txt"); while((line=sr.Readline())!=null) { file="\""+line+"\\r\\n";\\editing the line read from the file sr.WriteLine(file); file=""; } } file 1 has abt 700 lines and file2 is destination...

          1 Reply Last reply
          0
          • A ayandelhi

            hi!! m back... this time i thinks its a very basic problem... i'm trying to copy all the contents of a file(a txt file of 700 lines) when i write it in another file, it writes 75% of text.... it leaves the rest... y??? i dont understand... i'm using stream reader n writer... is it the way to do it..

            L Offline
            L Offline
            Luc Pattyn
            wrote on last edited by
            #5

            if you want help with your code, do not tell us anything or show us any code! The easy ways out: File.Copy File.WriteAllBytes(File.ReadAllBytes()) :)

            Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

            Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

            1 Reply Last reply
            0
            • A ayandelhi

              hi!! m back... this time i thinks its a very basic problem... i'm trying to copy all the contents of a file(a txt file of 700 lines) when i write it in another file, it writes 75% of text.... it leaves the rest... y??? i dont understand... i'm using stream reader n writer... is it the way to do it..

              K Offline
              K Offline
              kevinnicol
              wrote on last edited by
              #6

              close your writer when your done, it's probably just not flushing... sw.close(); also your are calling write line on a stream reader instead of your stream writer...

              A 2 Replies Last reply
              0
              • K kevinnicol

                close your writer when your done, it's probably just not flushing... sw.close(); also your are calling write line on a stream reader instead of your stream writer...

                A Offline
                A Offline
                ayandelhi
                wrote on last edited by
                #7

                sorry.. it was sw.WriteLine() ok.. so let me see it..

                1 Reply Last reply
                0
                • K kevinnicol

                  close your writer when your done, it's probably just not flushing... sw.close(); also your are calling write line on a stream reader instead of your stream writer...

                  A Offline
                  A Offline
                  ayandelhi
                  wrote on last edited by
                  #8

                  its working now.. thanks... thank u very much...

                  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