博客
关于我
asp.net 4.5 练习~test14-6 streamwrite写文件
阅读量:303 次
发布时间:2019-03-03

本文共 1177 字,大约阅读时间需要 3 分钟。

webform1.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="test14_6.WebForm1" %>

添加新词条

webform1.aspx.cs

using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;namespace test14_6{    public partial class WebForm1 : System.Web.UI.Page    {        protected void Page_Load(object sender, EventArgs e)        {        }        protected void Button1_Click(object sender, EventArgs e)        {            string path = Server.MapPath("test.txt");            string title = TextBox1.Text;            string word = TextBox2.Text;            System.IO.FileInfo file = new System.IO.FileInfo(path);            if (file.Exists == false)            {                System.IO.StreamWriter write1 = file.CreateText();                write1.WriteLine(title);                write1.WriteLine(word);                write1.Flush();                write1.Close();                lblTips.Text = "创建文件并写入数据成功!";            }        }    }}

 

转载地址:http://kdrm.baihongyu.com/

你可能感兴趣的文章
MySQL_属性、记录长度、设计范式、表关系
查看>>
MySQL_安全管理、表单传值、php操作
查看>>
POJ 3468 A Simple Problem with Integers(线段树+区间更新)
查看>>
BUUCTF web WarmUp
查看>>
hcnp笔记
查看>>
python数据分析
查看>>
MySQL(四)数据库结构设计
查看>>
Mybatis-plus 常用注解
查看>>
mybatis 如何切割字符串 查询多个值
查看>>
9.5 正则表达式及字符串的替换与分解
查看>>
在所有情况下取到顶层对象
查看>>
解构赋值
查看>>
封装vue的弹窗组件
查看>>
Qt错误:extra qualification " " on member ‘ ’|Qt
查看>>
qt Event
查看>>
串的基本操作实现源码|数据结构
查看>>
数据查询(3.4)
查看>>
实验二 进程创建实验
查看>>
qtDesigner中添加QAction
查看>>
[0115ZIZI]扩展P5.js库相关链接
查看>>