Last active
November 14, 2016 10:14
-
-
Save auycro/8fb6178b2d213d783af0e4330cc907f7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| // Created by Gumpanat Keardkeawfa on 11/14/16. | |
| // Copyright © 2016 Auycro. All rights reserved. | |
| using System; | |
| using System.IO; | |
| using System.Text; | |
| namespace FileConvertCommaAsciiToChar | |
| { | |
| class MainClass | |
| { | |
| static string[] files; | |
| public static void Main (string[] args) | |
| { | |
| if (args.Length < 1) { | |
| Console.WriteLine ("No parameter found"); | |
| return; | |
| } | |
| files = GetFiles (args[0]); | |
| //ListFilesName (files); | |
| Console.WriteLine ("Hello World! "+files.Length); | |
| //ReadAllLine (files [0]); | |
| SaveFileWithEn (files [0]); | |
| } | |
| public static string[] GetFiles(string rootfolder){ | |
| return Directory.GetFiles(rootfolder, "*.txt", SearchOption.AllDirectories); | |
| } | |
| public static void ListFilesName(string[] files){ | |
| foreach(string file in files) | |
| Console.WriteLine (file); | |
| } | |
| public static string ConvertHtmlDecodeToChar(string line){ | |
| return line | |
| .Replace (",", ","); | |
| //.Replace ("!", "!") | |
| } | |
| public static void ReadAllLine(string filename){ | |
| Console.WriteLine ("ReadAllLine :"+filename); | |
| string[] lines = System.IO.File.ReadAllLines(filename); | |
| foreach (string line in lines) | |
| { | |
| // Use a tab to indent each line of the file. | |
| Console.WriteLine("\t" + ConvertHtmlDecodeToChar(line)); | |
| } | |
| } | |
| public static void SaveFileWithEn(string file){ | |
| var path = Path.GetDirectoryName (file); | |
| //var fileName = Path.GetFileNameWithoutExtension (file)+"_en.txt"; | |
| var fileName = Path.GetFileName(file); | |
| var outputFileName = Path.Combine (path, fileName); | |
| using (StreamWriter outputfile = (File.Exists(outputFileName)) ? File.AppendText(outputFileName) : File.CreateText(outputFileName)) | |
| { | |
| string[] lines = System.IO.File.ReadAllLines(file); | |
| foreach (string line in lines) | |
| { | |
| // Use a tab to indent each line of the file. | |
| outputfile.WriteLine(ConvertHtmlDecodeToChar(line)); | |
| } | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment