//xml字符串
string xmlContent = "1234567";
using (FileStream fs = new FileStream(xmlFilePath, FileMode.Create, FileAccess.Write))
{
byte[] buffer = Encoding.UTF8.GetBytes(xmlContent);
fs.Write(buffer, 0, buffer.Length);
}
using (StreamWriter sw = new StreamWriter(xmlFilePath, false, Encoding.UTF8))
{
sw.Write(xmlContent);
}