2013-6-28-StreamWriter写入器

1.web

 StreamWriter sw = new StreamWriter(AppDomain.CurrentDomain.BaseDirectory + "/xmuser_add.txt", true, Encoding.UTF8);
                        sw.WriteLine("1");
                        sw.Close();




StreamWriter即写入器 ,来自System.IO 命名空间,其包含允许读写文件和数据流的类型以及提供基本文件和目录支持的类型。

//1.既然我们要对文件写入内容,就必须知道对哪个文件写入内容,故这里是获取要写的文件路径

string filePath= AppDomain.CurrentDomain.BaseDirectory + "/manage/webindexdesign/file.html";

//2.使用文件路径创建写入器

            using (StreamWriter sw = new StreamWriter(filePath))

            {

//3.使用Write方法向文件写内容(注意:write方法第一次写时会将文件清空,以后再写时就是追加内容了)

                sw.Write("<!DOCTYPE html><html id=\"htmlidflag\" xmlns=\"http://www.w3.org/1999/xhtml\">");
                sw.Write("<head id=\"headflagid\">");
                sw.Write(decodehead);

                sw.Write("</head>");

             }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值