using System.IO;
using System.Text;
namespace WebApplication1
{
public partial class WriteFile : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{}
protected void btnWrite_Click(object sender, EventArgs e)
{
string FileName = "./FileText.txt";
FileStream fs = new FileStream(Server.MapPath(FileName), FileMode.OpenOrCreate, FileAccess.ReadWrite);
byte[] FileByle = new byte[Encoding.UTF8.GetByteCount(tbContent.Text)];
FileByle = Encoding.UTF8.GetBytes(tbContent.Text);
fs.Write(FileByle, 0, FileByle.Length);
fs.Close();
fs.Dispose();
Response.Write("write file is ok");
}
}
}
File Write
最新推荐文章于 2023-04-04 14:08:28 发布