Created
October 27, 2018 18:25
-
-
Save TomasDrozdik/943b8c36245cdeada2b7e20b3f83b292 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
using System.IO; | |
namespace ConsoleApp1 | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
try { | |
using (StreamReader sr = new StreamReader(args[0])) { | |
using (StreamWriter sw = new StreamWriter(args[0] + ".cs.txt")) { | |
string line; | |
while ((line = sr.ReadLine()) != null) { | |
StringBuilder sb = new StringBuilder(line); | |
for (int i = 0; i < sb.Length; ++i) { | |
if (sb[i] == '"') { | |
sb.Insert(i, '\\'); | |
++i; | |
} | |
} | |
sb.Insert(0, "w.WriteLine(\""); | |
sb.Append("\");"); | |
sw.WriteLine(sb.ToString()); | |
} | |
} | |
} | |
} | |
catch (IOException) { | |
Console.WriteLine("Argument Error!"); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment