原文发布时间为: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);
    }
}

net8:文本文件的创建及其读写的更多相关文章

  1. C# 对文本文件的几种读写方法总结

    计算机在最初只支持ASCII编码,但是后来为了支持其他语言中的字符(比如汉字)以及一些特殊字符(比如€),就引入了Unicode字符集.基于Unicode字符集的编码方式有很多,比如UTF-7.UTF ...

  2. 消息队列的创建与读写ftok,msgget,msgsnd,msgrcv,指令ipcs,ipcrm 查看,删除消息队列

    ipcs是Linux下显示进程间通信设施状态的工具.可以显示消息队列.共享内存和信号量的信息.对于程序员非常有用,普通的系统管理员一般用不到此指令. ipcs -q 查看系统使用的IPC队列资源 ip ...

  3. C#创建、读写、增加、删除XML操作

    using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threa ...

  4. 【aardio】]SQL创建、读写 excel

    import access; var db,err = access( "/test.xls" ) //文件不存在可自动创建 //创建表 if( ! db.existsTable( ...

  5. Java之文本文件的创建和读取(含IO流操作)

    工具类:对文件的读取,创建.直接复制拿来用! package cn.zyzpp.util; import java.io.BufferedReader; import java.io.Buffered ...

  6. C#创建cookie读写cookie

    一.创建cookie HttpCookie cookie = new HttpCookie("UserInfo");//创建多值cookie              cookie ...

  7. 管道的创建与读写pipe

    1.管道的创建 #include <unistd.h> int pipe(int pipefd[2]); linux下创建管道可以通过函数pipe来完成.该函数如果调用成功,数组中将包含两 ...

  8. WinForm 创建与读写配置文件

    (转自:http://www.cnblogs.com/SkySoot/archive/2012/02/08/2342941.html) 1. 创建 app.config 文件: 右击项目名称,选择“添 ...

  9. Linux学习之路4——文件IO打开、创建、读写操作

    1.使用man 2 open.man 2 creat.man 2 write.man 2 read命令获取头文件 语法: int open(const char *pathname, int flag ...

随机推荐

  1. EMVS: Event-based Multi-View Stereo 阅读笔记

    0. 摘要 EMVS目的:从已知轨迹的event相机,估计半稠密的3D结构 传统的MVS算法目的:从已知视点的图片集,去估计场景的稠密3D结构. EMVS2个固有属性: (1)   当传感器发生相对运 ...

  2. Linux文件操作函数

    creat() 函数 close() 函数 read() 函数 read 函数实际读到的字节数少于要求读的字节数时: 读普通文件,在读到要求字节数之前就到达文件尾: 当从终端设备读,通常一次最多读一行 ...

  3. C# 队列Queue

    using System; using System.Collections.Generic; using System.Linq; namespace Queue测试 { class Program ...

  4. vuejs 的错误代码,有助于理解

    1.vuejs 的双向绑定理解 2.嵌套复杂对象的使用. * 1. 分割都是, 2. json 中分割都是; 4. v-bind:value="param" 括号内的就是 vuej ...

  5. 简单的Redis数据迁移

    dump迁移 1.安装redis-dump工具 sudo apt-get install ruby rubygems ruby-devel -y gem sources --add http://ge ...

  6. 老男孩Python高级全栈开发工程师【真正的全套完整无加密】

    点击了解更多Python课程>>> 老男孩Python高级全栈开发工程师[真正的全套完整无加密] 课程大纲 老男孩python全栈,Python 全栈,Python教程,Django ...

  7. Spring中使用注解 @Scheduled 执行定时任务

    来自:http://blog.51cto.com/dwf07223/1557145 注解@Scheduled 可以作为一个触发源添加到一个方法中,例如,以下的方法将以一个固定延迟时间5秒钟调用一次执行 ...

  8. mem之读操作调式总结(跟入栈出栈有关)

    现象: 1.当case比较复杂的时候(含有for循环对mem进行读/写) 发现for循环时总是有汇编指令不执行跳过去了,(其实是汇编不熟和指令太多无法理智分析指令了). 事实是指令是对的,但执行错了( ...

  9. DFS:POJ3620-Avoid The Lakes(求最基本的联通块)

    Avoid The Lakes Time Limit: 1000MS Memory Limit: 65536K Description Farmer John's farm was flooded i ...

  10. Ubuntu 16.04上thunderbird配置163邮箱出现“配置无法被验证-请查看用户名或密码是否正确?”

    在Ubuntu 16.04 上用thunderbird配置163免费邮箱时出现的提示信息如图1: 图1 提示信息 网上有不少方法都说是将接收和发出的主机名分别改为 imap.ym.163.com 和 ...