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. Visual Basic
  4. helloooooooooooooooooo its urgent

helloooooooooooooooooo its urgent

Scheduled Pinned Locked Moved Visual Basic
helpquestion
7 Posts 4 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
    imanos
    wrote on last edited by
    #1

    hi friends, please can anyway one help me if i can modify a file. i mean delete some sentences from it and save it without writing its content to another file and then overwrite it?

    emma :)

    T C 2 Replies Last reply
    0
    • I imanos

      hi friends, please can anyway one help me if i can modify a file. i mean delete some sentences from it and save it without writing its content to another file and then overwrite it?

      emma :)

      T Offline
      T Offline
      theScorp
      wrote on last edited by
      #2

      Well u can use.. System.IO.File.ReadAllLines OR System.IO.File.ReadAllText then Modify string and then write using System.IO.File.WriteAllLines OR System.IO.File.WriteAllText Bt keep in mind this will overwrite the file.


      "If our Mind can, the Program can !!" ≡ ░Ŗǿђầŋ٭ ≡

      I 1 Reply Last reply
      0
      • I imanos

        hi friends, please can anyway one help me if i can modify a file. i mean delete some sentences from it and save it without writing its content to another file and then overwrite it?

        emma :)

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

        imanos wrote:

        helloooooooooooooooooo its urgent

        That sort of subject is not helpful, it doesn't describe your problem at all.

        imanos wrote:

        i mean delete some sentences from it and save it without writing its content to another file and then overwrite it?

        To do this, use System.IO.File.ReadAllText to read the file, modify it in memory, then use File.WriteAllText to save it again.

        Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

        P 1 Reply Last reply
        0
        • C Christian Graus

          imanos wrote:

          helloooooooooooooooooo its urgent

          That sort of subject is not helpful, it doesn't describe your problem at all.

          imanos wrote:

          i mean delete some sentences from it and save it without writing its content to another file and then overwrite it?

          To do this, use System.IO.File.ReadAllText to read the file, modify it in memory, then use File.WriteAllText to save it again.

          Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

          P Offline
          P Offline
          Paul Conrad
          wrote on last edited by
          #4

          Christian Graus wrote:

          imanos wrote: helloooooooooooooooooo its urgent That sort of subject is not helpful, it doesn't describe your problem at all.

          No it doesn't. Even if he says it outside a Port-a-Potty with a guy taking a long time inside :laugh:

          I 1 Reply Last reply
          0
          • T theScorp

            Well u can use.. System.IO.File.ReadAllLines OR System.IO.File.ReadAllText then Modify string and then write using System.IO.File.WriteAllLines OR System.IO.File.WriteAllText Bt keep in mind this will overwrite the file.


            "If our Mind can, the Program can !!" ≡ ░Ŗǿђầŋ٭ ≡

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

            thanks :) u know what i've tried it but it works just fine for small files as for big ones it's not very helpfull anyother way?

            emma :)

            1 Reply Last reply
            0
            • P Paul Conrad

              Christian Graus wrote:

              imanos wrote: helloooooooooooooooooo its urgent That sort of subject is not helpful, it doesn't describe your problem at all.

              No it doesn't. Even if he says it outside a Port-a-Potty with a guy taking a long time inside :laugh:

              I Offline
              I Offline
              imanos
              wrote on last edited by
              #6

              well thanks, ill clear it, i have 2 files and i want to delete the words in the first one from the second one knowing that i don't want to create new file and write the old one again without the unwanted words i.e. i want to modify the file and save it

              emma :)

              P 1 Reply Last reply
              0
              • I imanos

                well thanks, ill clear it, i have 2 files and i want to delete the words in the first one from the second one knowing that i don't want to create new file and write the old one again without the unwanted words i.e. i want to modify the file and save it

                emma :)

                P Offline
                P Offline
                Paul Conrad
                wrote on last edited by
                #7

                imanos wrote:

                i don't want to create new file and write the old one again

                Why not? Just create a temporary file with the new list of wanted words, rename the original first file, and rename the temporary file to the original name of the first file...

                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