Type of issue
Code does not work
Description
internal static void DeleteFromFile(FileInfo file, string[] searchTerms)
{
Console.WriteLine("Deleting from file");
var lines = File.ReadLines(file.FullName).Where(line => searchTerms.All(s => !line.Contains(s)));
File.WriteAllLines(file.FullName, lines);
}
-delete command execute throw System.IO.IOException;
fix example:
var lines = File.ReadLines(file.FullName).Where(line => searchTerms.All(s => !line.Contains(s))).ToList();
Page URL
https://learn.microsoft.com/en-us/dotnet/standard/commandline/get-started-tutorial
Content source URL
https://github.com/dotnet/docs/blob/main/docs/standard/commandline/get-started-tutorial.md
Document Version Independent Id
fa160b1d-66ed-8c5d-37cd-b7e02443e9f1
Platform Id
0f144444-1ce3-cdf7-87a6-c659d44e08d3
Article author
@gewarren
Metadata
- ID: 7705dc41-7297-0807-7e9c-2e6548c26b84
- PlatformId: 0f144444-1ce3-cdf7-87a6-c659d44e08d3
- Service: dotnet-fundamentals
Related Issues
Type of issue
Code does not work
Description
-delete command execute throw System.IO.IOException;
fix example:
var lines = File.ReadLines(file.FullName).Where(line => searchTerms.All(s => !line.Contains(s))).ToList();
Page URL
https://learn.microsoft.com/en-us/dotnet/standard/commandline/get-started-tutorial
Content source URL
https://github.com/dotnet/docs/blob/main/docs/standard/commandline/get-started-tutorial.md
Document Version Independent Id
fa160b1d-66ed-8c5d-37cd-b7e02443e9f1
Platform Id
0f144444-1ce3-cdf7-87a6-c659d44e08d3
Article author
@gewarren
Metadata
Related Issues