Selaa lähdekoodia

added pause, removed log on each checked file

Veloe 1 vuosi sitten
vanhempi
commit
c8bded00cf

+ 4 - 2
StringReplacer/Program.cs

@@ -148,7 +148,6 @@ public static class Program
                 foreach (var file in files)
                 {
                     var encodingString = magic.Read(file);
-                    _proccess_encode_logger.Information("{0}: {1}",file, encodingString);
                     Encoding encoding = Encoding.GetEncoding("windows-1251");
 
                     switch (encodingString)
@@ -161,7 +160,7 @@ public static class Program
                             encoding = Encoding.GetEncoding("windows-1251");
                             break;
                         default:
-                            _logger.Warning("Encoding not recognized for {0}. Using {1} as default", file, encoding.HeaderName);
+                            _logger.Warning("Encoding not recognized for {0} with mime-encoding {1}. Using {2} as default", file, encodingString, encoding.HeaderName);
                             break;
                     }
 
@@ -169,6 +168,7 @@ public static class Program
 
                     if (Regex.IsMatch(content,$"\\b{word_Find}\\b"))
                     {
+                        _proccess_encode_logger.Information("{0}: {1}", file, encodingString);
                         File.WriteAllText(file, Regex.Replace(content, $"\\b{word_Find}\\b", word_Replace), encoding);
                         _logger.Information("Replaced in {0}; mime-encoding: {1}; used encoding: {2}", file, encodingString, encoding.HeaderName);
                     }
@@ -188,6 +188,8 @@ public static class Program
                 innerException = innerException.InnerException;
             }
         }
+        Console.WriteLine("Press any key to close this window . . .");
+        Console.ReadKey();
     }
 
     private static bool ValidateArg(string arg, bool throwException = false, string? argName = null) => !arg.StartsWith('-') && !string.IsNullOrEmpty(arg) || (throwException ? throw new ArgumentException(string.Format("Argument is not vaild {0}",arg),argName ?? nameof(arg)) : false);

+ 0 - 8
StringReplacer/Properties/launchSettings.json

@@ -1,8 +0,0 @@
-{
-  "profiles": {
-    "StringReplacer": {
-      "commandName": "Project",
-      "commandLineArgs": "-p C:\\Users\\Veloe\\Desktop\\TestFolder1 -e *.pas"
-    }
-  }
-}

+ 2 - 2
StringReplacer/StringReplacer.csproj

@@ -5,8 +5,8 @@
     <TargetFramework>net7.0</TargetFramework>
     <ImplicitUsings>enable</ImplicitUsings>
     <Nullable>enable</Nullable>
-    <AssemblyVersion>1.1.0.10</AssemblyVersion>
-    <FileVersion>1.1.0.10</FileVersion>
+    <AssemblyVersion>1.1.0.11</AssemblyVersion>
+    <FileVersion>1.1.0.11</FileVersion>
   </PropertyGroup>
 
   <ItemGroup>