Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 899417
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T15:12:51+00:00 2026-05-15T15:12:51+00:00

I have a web app that I am developing at work. I need to

  • 0

I have a web app that I am developing at work. I need to be able to take input data and append a text file after (x) number of lines.

My web app is using asp.net with c#

Can anyone help me please?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T15:12:52+00:00Added an answer on May 15, 2026 at 3:12 pm

    There’s no way of “inserting” into a file in general – or of going to a specific line, without reading all the others, unless they’re of a fixed size (in bytes).

    Normally the approach would be something like:

    • Start writing a new file
    • Open the existing file
    • Copy the first x lines from the old file to the new one
    • Write the new line
    • Copy the remaining lines from the old file to the new one
    • Move the old one to a backup file
    • Move the new file to the old name
    • Delete the backup file

    (This ensures that at any one point there’s at least the old file in some form. You can make it slightly simpler if you just delete the old file and then move the new one into place.)

    Don’t forget to ensure this is synchronized appropriately – you don’t want to have two copies of this algorithm running at the same time…

    EDIT: If you’ve got XML files, then I’d suggest usually just loading it into the DOM (e.g. with LINQ to XML), making the change, and then saving it out again. Don’t treat it just like an unstructured text file.

    You could potentially make this more efficient using XmlReader and XmlWriter – but you’re certainly going to have to read the whole original file and write out the new file. Have you benchmarked simple code and found it too slow? How often are you doing this? How big are the files?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing a web app that will have two parts running on two
I have a web app that reads data from a SQL DB that contains
I'm developing a web app where i have a form like that <form name=form
I am developing a web app that is supposed to have the feeling of
I am developing a web app that accesses some external JSON data. I'm currently
I am developing a web app that sends out emails. Currently, all emails have
I'm developing a java web app on my local PC that uses a file
I have a web app that runs fine in Visual web developer. But when
I have a web app that has a big and complex form (fields, checks,
We have an web app that is talking to Netsuite via Netsuite's web services.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.