// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Collections.Generic; using System.IO; namespace E { public class Program { public static void Replace(string infnm, string outfnm, Dictionary replace) { StreamReader sr = new StreamReader(infnm); string content = sr.ReadToEnd(); sr.Close(); foreach(string key in replace.Keys) { content = content.Replace(key, replace[key]); } StreamWriter sw = new StreamWriter(outfnm); sw.Write(content); sw.Close(); } public static void Main(string[] args) { Dictionary replace = new Dictionary(); replace.Add("$XXX$", "Id"); replace.Add("$YYY$", "X"); replace.Add("$ZZZ$", "1"); replace.Add("$WWW$", "177.49"); Replace(@"C:\test.rtf", @"C:\test2.rtf", replace); } } }