public void TextWriterUtility_Append_1()
        {
            Encoding encoding = Encoding.ASCII;

            string fileName = Path.GetTempFileName();

            File.WriteAllText(fileName, "Hello, ", encoding);
            using (TextWriter writer = TextWriterUtility.Append(fileName, encoding))
            {
                writer.Write("world!");
            }
            string actual = File.ReadAllText(fileName, encoding);

            Assert.AreEqual("Hello, world!", actual);
        }
Exemplo n.º 2
0
        public FileLogger WriteLine
        (
            [CanBeNull] string line
        )
        {
            if (!ReferenceEquals(line, null))
            {
                using (StreamWriter writer = TextWriterUtility.Append
                                             (
                           FileName,
                           Encoding.UTF8
                                             ))
                {
                    writer.WriteLine(line);
                }
            }

            return(this);
        }