string jsonStr = JsonConvert.SerializeObject(data); FileStream stream = new FileStream(@"C:\Users\YeChangZhong\Desktop\新建文件夾\aa.txt", FileMode.Create);//fileMode指定是讀取仍是寫入 StreamWriter writer = new StreamWriter(stream); writer.WriteLine("===================="); writer.WriteLine(jsonStr); writer.WriteLine(data.CREATEUSERNAME); writer.WriteLine(data.MODIFYUSERNAME); writer.WriteLine("===================="); writer.Close();//釋放內存 stream.Close();//釋放內存