Ryan
Ryan

Reputation: 1

Deleting lines from text file

I'm making a multiple questions quiz on the console application. What I am trying to complete right now is the updating/deleting of questions.

I would really appreciate any help and also note that I'm new so if I have missed anything please let me know as I am not familiar with Stack Overflow.

I would prefer to use streamreader and writer to read and write to the file as I am a little familiar with these.

Here is my code structure for the variables to be saved in the textfile.

public struct Questions
    {
        public int 
               Level,               //1
               Qnum;                //2

        public string 
               Q,                   //The capital of England A)? B)London C)? D)?
               A;                   //B
    }

I feel ridiculous as if I should know how to do this but I am just not capable of doing it, any help is much appreciated.

Upvotes: 0

Views: 2211

Answers (1)

AlexC
AlexC

Reputation: 402

You have to read the file and store the string in your code, then remove the line from the string and write it back on the file.

Take a look at this question's answer if you need more details

Delete specific line from a text file?

Upvotes: 1

Related Questions