zoukankan      html  css  js  c++  java
  • net8:文本文件的创建及其读写

    原文发布时间为:2008-08-06 —— 来源于本人的百度文章 [由搬家工具导入]

    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;


    using System.IO;
    using System.Text;

    public partial class Default3 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected void Button1_Click(object sender, EventArgs e)
        {//create and write
            string info = TextBox1.Text;
            string name = TextBox3.Text;

            FileStream fs = new FileStream(Server.MapPath("~/txt/" + name + ".txt"), FileMode.Create, FileAccess.Write);
            StreamWriter sw = new StreamWriter(fs, Encoding.Default);
            sw.WriteLine(info);
            sw.Close();
            fs.Close();
            Response.Write("<script>alert('Create " + name + ".txt')</script>");

        }
        protected void Button2_Click(object sender, EventArgs e)
        {//read
            string name = TextBox4.Text;
            TextBox2.Text = File.ReadAllText(Server.MapPath("~/txt/" + name + ".txt"), Encoding.Default);
        }
    }

  • 相关阅读:
    MySQL数据库小结
    使用Python操作MySQL数据库
    MySQL索引原理
    MySQL性能分析之Explain
    201907 TIOBE 编程语言排行榜-Python坐稳第三
    MySQL索引的数据结构-B+树介绍
    MySQL多表查询综合练习答案
    MySQL记录操作
    MySQL多表查询
    javascript实现无缝上下滚动(转)
  • 原文地址:https://www.cnblogs.com/handboy/p/7143824.html
Copyright © 2011-2022 走看看