dcsimg
Results 1 to 12 of 12

Thread: Replace content of file

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Dec 2017
    Posts
    19

    Replace content of file

    HI, I wonder how can I replace content of text file from another text file

  2. #2
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,143

    Re: Replace content of file

    What have you tried so far? We are not here to write your project for you.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Dec 2017
    Posts
    19

    Re: Replace content of file

    Well I was trying to follow File.Replace Method from msdn site. But it doesn't work
    Public Class Form1

    Private File As String = ("..\..\TextFile\fillDrinks.txt")
    Private FileToReplace As String = %2
    Last edited by BloodySandwich; Jan 22nd, 2018 at 05:03 PM.

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Dec 2017
    Posts
    19

    Re: Replace content of file

    Same yellow error again....

  5. #5
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,143

    Re: Replace content of file

    don't edit your code so it makes no sense unless previously seen. Lets look at the basics first, One field has an extension of txt. Whats the other.

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Dec 2017
    Posts
    19

    Re: Replace content of file

    Second file is also txt

  7. #7

  8. #8

    Thread Starter
    Junior Member
    Join Date
    Dec 2017
    Posts
    19

    Re: Replace content of file

    Yes,exactly.

  9. #9
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,143

    Re: Replace content of file

    Urgh, your original code did not have the extension of the second file. But you edited it and removed it. Making this thread a mess.

  10. #10

    Thread Starter
    Junior Member
    Join Date
    Dec 2017
    Posts
    19

    Re: Replace content of file

    I didn't remove anything, for some reason is gone.
    fillDrinks.txt
    drinks.txt

  11. #11
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,143

    Re: Replace content of file

    Of course. Last edited by BloodySandwich; Today at 10:03 PM.

  12. #12
    Addicted Member
    Join Date
    Aug 2017
    Location
    Nigeria
    Posts
    238

    Re: Replace content of file

    I think if you want to replace(overwrite) the contents of one with the other I think you should use stream reader and read the file from the first one the use stream writer to write to the second fie.
    Nothing I post is Self Reliable. Use it at your own risk

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width