StreamWriter
string _FileText = "some text"; using (System.IO.StreamWriter _StreamWriter = new System.IO.StreamWriter("PathFile")) { _StreamWriter.Write(_FileText); _StreamWriter.Flush(); } using (System.IO.StreamWriter _StreamWriter = new System.IO.StreamWriter("PathFile")) { foreach (System.IO.DirectoryInfo _DirectoryInfo in new DirectoryInfo(@"c:\").GetDirectories()) { _StreamWriter.WriteLine(_DirectoryInfo.Name); } } MSDN Artikel