35 lines
1.1 KiB
C#
35 lines
1.1 KiB
C#
using Microsoft.Extensions.Logging;
|
|
|
|
namespace File_Folder_Helper.Day.Q42023;
|
|
|
|
internal static class Helper20231102
|
|
{
|
|
|
|
internal static void NuSpec(ILogger<Worker> logger, string argsZero)
|
|
{
|
|
string[] lines;
|
|
string? idLine;
|
|
string? versionLine;
|
|
string[] files = Directory.GetFiles(argsZero);
|
|
logger.LogInformation("{fileCount}", files.Length.ToString());
|
|
foreach (string file in files)
|
|
{
|
|
idLine = null;
|
|
versionLine = null;
|
|
lines = File.ReadAllLines(file);
|
|
foreach (string line in lines)
|
|
{
|
|
if (!line.EndsWith("</id>") && !line.EndsWith("</version>"))
|
|
continue;
|
|
if (line.EndsWith("</id>"))
|
|
idLine = line.TrimEnd();
|
|
if (line.EndsWith("</version>"))
|
|
versionLine = line.TrimEnd();
|
|
if (idLine is not null && versionLine is not null)
|
|
break;
|
|
}
|
|
File.AppendAllText(".txt", $"{idLine}{versionLine}{Environment.NewLine}");
|
|
}
|
|
}
|
|
|
|
} |