gh0st-sniper
❔ how do I select a specific text from the file and delete it and it's corresponding contents in C
static void Cancel()
{
StreamReader customercancel = new StreamReader("customerdetails.txt");
while(customercancel.EndOfStream == false)
{
string line = customercancel.ReadLine();
Console.WriteLine(line);
}
//customercancel.Close();
Console.Write("Select the name you want to cancel the appointment");
string namecancel = Console.ReadLine();
File.ReadLines("customerdetails.txt")
.SkipWhile(line => !line.Contains(namecancel))
.Skip(1)
.TakeWhile(line => !line.Contains(namecancel));
}
static void Staff()
{
StreamReader staffavailability = new StreamReader("staff1.txt");
for (int i = 0; i < 10; i++)
{
string line = staffavailability.ReadLine();
Console.WriteLine(line);
}
staffavailability.Close();
}
}
static void Cancel()
{
StreamReader customercancel = new StreamReader("customerdetails.txt");
while(customercancel.EndOfStream == false)
{
string line = customercancel.ReadLine();
Console.WriteLine(line);
}
//customercancel.Close();
Console.Write("Select the name you want to cancel the appointment");
string namecancel = Console.ReadLine();
File.ReadLines("customerdetails.txt")
.SkipWhile(line => !line.Contains(namecancel))
.Skip(1)
.TakeWhile(line => !line.Contains(namecancel));
}
static void Staff()
{
StreamReader staffavailability = new StreamReader("staff1.txt");
for (int i = 0; i < 10; i++)
{
string line = staffavailability.ReadLine();
Console.WriteLine(line);
}
staffavailability.Close();
}
}
3 replies