Results 1 to 3 of 3

Thread: [RESOLVED] could u say "how to write data in a specific line of a file"?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2007
    Posts
    167

    Resolved [RESOLVED] could u say "how to write data in a specific line of a file"?

    Hi every body,
    Till now i have used "Files" concept in V.B for many times. but i don't know how to write data in a specific line.

    till now how i wrote was like the following sentence.

    print #iFileNo,strStudentName

    If you know how to do this, kindly let me know it..

    Thanks:
    regards:
    raghunadhs.

  2. #2
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: could u say "how to write data in a specific line of a file"?

    What i normally do is,

    assume you have a file call a.txt with 10 lines.
    so you want inset a line in to the 5th line.

    You read the lines of a.txt using a loop and write top 4 lines in to a new file call b.txt . when the loop reached the 5th line, you write your new line in to the b.txt and write the rest of the lines in to b.txt as you wrote the top 4 lines.

    After writing all the lines, you just delete a.txt and rename b.txt to a.txt.

    I dont know any other direct solutions are there. You can use this as a temporary solution.


  3. #3

    Thread Starter
    Addicted Member
    Join Date
    May 2007
    Posts
    167

    Re: could u say "how to write data in a specific line of a file"?

    Thanks Fazi,
    i will follow up your suggestion...
    Thanks:
    regards:
    raghunadhs.
    [QUOTE=Fazi]What i normally do is,

    assume you have a file call a.txt with 10 lines.
    so you want inset a line in to the 5th line.

Posting Permissions

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



Click Here to Expand Forum to Full Width