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 6699261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:40:28+00:00 2026-05-26T06:40:28+00:00

Hi i all having a requirement to delete particular data from a text file.

  • 0

Hi i all having a requirement to delete particular data from a text file. I have written some code to get my exact data to remove but now i am little bit confused in removing that particular data can any one help me.

Initially this is my data in text file where i am storing to a Stringbuilder

101 111111111 1111111111110150105A094101                                                      

52201               1                   1         PPD1         111015111015   1111000020000001

6241110000251                00000000011              1                     1 0111000020000001

822000000100111000020000000000000000000000011                                  111000020000001

52251               1                   1         PPD1         011015111015   1111000020000002

6281110000251                00000000011              1                     1 0111000020000002

822500000100111000020000000000010000000000001                                  111000020000002

9000002000001000000020022200004000000000001000000000001                                       

Now by using certain code i am getting the data to delete i.e assume i would like to delete from 5 to 8 which exists. I am storing this to another StringBuilder as follows

52251               1                   1         PPD1         011015111015   1111000020000002

6281110000251                00000000011              1                     1 0111000020000002

822500000100111000020000000000010000000000001                                  111000020000002

I would like to remove this from the main Stringbuilder i am having. Is this the correct process or if any better way let me know

enter image description here

  • 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-26T06:40:28+00:00Added an answer on May 26, 2026 at 6:40 am

    You could use StringBuilder.Replace.

    sb1.Replace(sb2.ToString(), "");
    

    But better is to iterate over the data you wish to keep and serialize it to the file again. Take care to overwrite the file atomically if you don’t want to risk losing data if the computer crashes while you are saving.

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

Sidebar

Related Questions

I have a MS-Visual Studio 2005 workspace having all c code. This application(exe) allocates
Having been given the all clear to move code from my Page_Loaded method to
I have a requirement for compiling large number of projects (some of them having
Hi all I am having a requirement where I have to assign multiple keys
I have a requirement where I have to fetch some records from the database
I have a dynamic data ASP.NET application with a requirement to give some users
Hi all I am having some problems that I think can be attributed to
Hi All I am currently having an issue calling a WCF service from a
all. I'm having a bit of weird problem with client server program. I have
I've found myself having a requirement to configure log4net based on a file relative

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.