FileStream fs = new FileStream(System.AppDomain.CurrentDomain.BaseDirectory + "log.txt",FileMode.Append); byte[] data1 = System.Text.Encoding.Default.GetBytes(eeee.Message); byte[] data2 = System.Text.Encoding.Default.GetBytes(eeee.StackTrace); fs.Write(data1,0,data1.Length); fs.Write(data2, 0, data2.Length); fs.Flush(); fs.Close();