Solved

delete a row in a file

Posted on 2004-09-26
6
199 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
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…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

813 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

9 Experts available now in Live!

Get 1:1 Help Now