class Bu { public string fileName { get; set; } = "hello.txt"; public string filecontent { get; set; } public void WriteText2File() { using (StreamWriter writer = File.CreateText(System.IO.Path.GetTempPath() + fileName)) { writer.WriteLine(filecontent); } Console.ReadLine(); } }