public static void Main(string[] args) { if (args.Length < 2) { Console.WriteLine("Usage: TextDescramble <dir> <*.ext>"); return; } Console.WriteLine("Directory : " + args[0]); Console.WriteLine("Files mask : " + args[1]); var ksFiles = Directory.EnumerateFiles(args[0], args[1], SearchOption.AllDirectories); foreach (string filePath in ksFiles) { Console.WriteLine("Parsing : " + filePath); //Directory.Move(filePath, Path.Combine(args[0] + "\\backup", filePath)); try { string content = Descrambler.Descramble(filePath); if (content == null || content == "") { return; } File.WriteAllText(filePath, content, Encoding.Unicode);// Encoding.UTF8); } catch (Exception ex) { Console.WriteLine(ex.Message); } } }
private static void DescrambleFolder(string folderPath) { string[] extensions = { ".ks", ".tjs", ".txt", ".csv", ".ini" }; foreach (string filePath in Directory.EnumerateFiles(folderPath, "*", SearchOption.AllDirectories)) { if (!extensions.Contains(Path.GetExtension(filePath)?.ToLower())) { continue; } try { string content = Descrambler.Descramble(filePath); if (content == null) { continue; } File.WriteAllText(filePath, content, Encoding.UTF8); Console.WriteLine($"Descrambled {filePath}"); } catch (Exception ex) { Console.WriteLine($"Failed to descramble {filePath}: {ex.Message}"); } } }
private static void DescrambleFile(string filePath) { try { string content = Descrambler.Descramble(filePath); if (content == null) { Console.WriteLine("File is not scrambled."); return; } File.WriteAllText(filePath, content, Encoding.UTF8); Console.WriteLine("File descrambled."); } catch (Exception ex) { Console.WriteLine($"Failed to descramble file: {ex.Message}"); } }