public ReformFiles() { bool leadWithComma = false; DirectoryInfo d = new DirectoryInfo(@".\Data"); //Assuming Test is your Folder FileInfo[] Files = d.GetFiles("*.csv"); //Getting Text files string str = ""; foreach (FileInfo infile in Files) { string line; string outFileName = Path.GetFileNameWithoutExtension(infile.FullName) + ".json"; System.IO.StreamReader infilestream = new System.IO.StreamReader(infile.FullName); System.IO.StreamWriter outfilestream = new System.IO.StreamWriter(infile.DirectoryName + "\\" + outFileName); outfilestream.WriteLine("["); while ((line = infilestream.ReadLine()) != null) { line = Regex.Replace(line, @"[^\u0000-\u007F]+", string.Empty); MagicItemInfo mii = Reformat(line); if (leadWithComma) { outfilestream.WriteLine(","); } outfilestream.WriteLine("{\r\n\t\"LowRoll\":" + mii.RollLow + ","); outfilestream.WriteLine("\t\"HighRoll\":" + mii.RollHigh + ","); outfilestream.WriteLine("\t\"Name\":\"" + mii.Description + "\","); outfilestream.WriteLine("\t\"Experience\":\"" + mii.Experience + "\","); outfilestream.WriteLine("\t\"Price\":\"" + mii.GPValue + "\""); outfilestream.Write("}"); leadWithComma = true; } outfilestream.WriteLine("\r\n]"); outfilestream.Close(); } }