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);
}
}
最新文章
- UVA 1513 Movie collection (树状数组+反向存储)
- 一步一步安装UEFI分区方式的windows 10 企业版
- swift_简单值 | 元祖 | 流程控制 | 字符串 | 集合
- SQL 最基本使用
- nodejs之process进程
- [原] XAF 如何基于业务规则禁用属性
- Tomcat热部署和虚拟目录配置
- FM000
- 【Sass初级】开始使用Sass和Compass
- OpenMP多线程linux下的使用,简单化
- java学习面向对象之static内存图解
- ActiveMQ之topic主题模式
- AlexNet卷积神经网络【前向反馈】
- qianduan
- restful规范快速记忆
- base64加密和解码原理和代码
- java加载配置文件信息
- 第3章 文件I/O(6)_高级文件操作:文件锁
- POJ 2395 Out of Hay(求最小生成树的最长边+kruskal)
- cat命令和EOF标识输出shell到文件
热门文章
- WPF中退出时显示是否保存数据提示
- python_111_动态导入模块
- LeetCode || 双指针 / 单调栈
- https 调用验证失败 peer not authenticated
- centos6 安装windows字体
- 老男孩Python高级全栈开发工程师【真正的全套完整无加密】
- vue+axios+promise实际开发用法
- Web框架之Django_04 模板层了解(过滤器、标签、自定义过滤器、标签、inclusion_tag、模板的继承与导入)
- python--第一类对象,函数名,变量名
- django基础(web框架,http协议,django安装)