将字符串写入记事本

    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();//释放内存

 

posted @ 2019-11-06 14:00  代码沉思者  阅读(334)  评论(0编辑  收藏  举报