ConvertToUTF8

This commit is contained in:
Mike Phares 2024-12-04 13:18:46 -07:00
parent ec98d1e275
commit cf531cff36
3 changed files with 38 additions and 0 deletions

12
.vscode/launch.json vendored
View File

@ -11,6 +11,18 @@
"preLaunchTask": "build",
"program": "${workspaceFolder}/bin/Debug/net8.0/win-x64/File-Folder-Helper.dll",
"args": [
"s",
"X",
"L:/DevOps/Mesa_FI/MesaFabApproval/Fab2ApprovalTests/Programmability/Functions",
"Day-Helper-2024-12-04",
"*.sql",
"333",
"444",
"555",
"666",
"777",
"888",
"999",
"s",
"X",
"L:/DevOps/Mesa_FI/MesaFabApproval",

View File

@ -0,0 +1,24 @@
using Microsoft.Extensions.Logging;
using System.Text;
namespace File_Folder_Helper.ADO2024.PI4;
internal static partial class Helper20241204
{
internal static void ConvertToUTF8(ILogger<Worker> logger, List<string> args)
{
string text;
string searchPattern = args[2];
string sourceDirectory = Path.GetFullPath(args[0]);
string[] files = Directory.GetFiles(sourceDirectory, searchPattern, SearchOption.TopDirectoryOnly);
if (files.Length == 0)
logger.LogError("No files found in {sourceDirectory} with search pattern {searchPattern}", sourceDirectory, searchPattern);
foreach (string file in files)
{
text = File.ReadAllText(file);
File.WriteAllText(file, text, Encoding.UTF8);
}
}
}

View File

@ -119,6 +119,8 @@ internal static class HelperDay
ADO2024.PI4.Helper20241108.WriteMarkdown(logger, args);
else if (args[1] == "Day-Helper-2024-11-15")
ADO2024.PI4.Helper20241115.GetComplete(logger, args);
else if (args[1] == "Day-Helper-2024-12-04")
ADO2024.PI4.Helper20241204.ConvertToUTF8(logger, args);
else
throw new Exception(appSettings.Company);
}