Solved

delete a row in a file

Posted on 2004-09-26
6
180 Views
Last Modified: 2010-04-23
I have a string like 2004-10-21 and the file looks like this

1999-01-01
2004-10-01
2004-09-30
2004-10-21

and i wan't to delete 2004-10-21 but leav the other dates intact how?
0
Comment
Question by:stromberg10
6 Comments
 
LVL 28

Accepted Solution

by:
iboutchkine earned 43 total points
ID: 12155988
You have to read file and write it to different file, When you found the string that you want to delete, don't write it. WHen you finished, delete the original file and rename the new one.
0
 
LVL 96

Assisted Solution

by:Bob Learned
Bob Learned earned 41 total points
ID: 12157004
Do you know how to read text files?  Is it possible to have multiple dates the same.  You could read the entire contents of the file into a string, replace the string with nothing, and then write the string back to the file.

Bob
0
 
LVL 10

Assisted Solution

by:123654789987
123654789987 earned 41 total points
ID: 12159293
try this. This is the code to remove the third string - 2004-09-30


                                                 str1 as string
                  str2 as string

                  str1 = "1999-01-01     2004-10-01    2004-09-30  2004-10-21"

            
                  length as int
                  fourthString as int

                  length = str1.Length()
                  fourthString = str1.IndexOf("2004-10-21")

                  str2 = str1.Remove(fourthString , length-fourthString) // This gives the final output string

0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now