In most cases you need to call tw.Flush()
and tw.Close()
(or just wrap new StreamWriter(..)
in using (...)
statement) before seeing results in file.
Even if it seems to start working with other file path (as you commented) - there's no magic (at least in programming) - and it will fail someday without proper Flush
/ Dispose
.