原文发布时间为: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. scrollviews page分页实现方式

    代码 buttonX = 0; buttonW = 50; buttonH = 20; margin = (self.view.width - 5 * buttonW) / 6; CGFloat ym ...

  2. mvc的model验证,ajaxhelper,验证机制语法

    ajaxhelper: onsuccess是调用成功后显示方法,还有一个方法是调用前显示 model验证: 控件前端验证: 需要引入的JS 其中第二个是ajaxhelper的必须验证 后台的两个同名不 ...

  3. Core Foundation 框架

    Core Foundation框架 (CoreFoundation.framework) 是一组C语言接口,它们为iOS应用程序提供基本数据管理和服务功能.下面列举该框架支持进行管理的数据以及可提供的 ...

  4. 5 Options for Distributing Your iOS App to a Limited Audience

    http://mobiledan.net/2012/03/02/5-options-for-distributing-ios-apps-to-a-limited-audience-legally/ I ...

  5. 机器学习(1)- 概述&线性回归&逻辑回归&正则化

    根据Andrew Ng在斯坦福的<机器学习>视频做笔记,已经通过李航<统计学习方法>获得的知识不赘述,仅列出提纲. 1 初识机器学习 1.1 监督学习(x,y) 分类(输出y是 ...

  6. chrom控制台常用方法

    console.assert对输入的表达式进行断言,只有表达式为false时,才输出相应的信息到控制台 . console.count(这个方法非常实用哦)当你想统计代码被执行的次数 console. ...

  7. Hdu 3177 (贪心)

    题目大意: 山洞的体积为\(v\) 第\(i\)个物品放在山洞里会占据\(a_i\)的空间,在搬运过程中至少需要\(b_i\)的空间 问能不能把所有物品都放下 贪心题.比较难看出贪心,但是从无顺序要求 ...

  8. 编译openwrt_MT7688_hiwooya

    参考链接: 无涯论坛地址: http://www.hi-wooya.com/forum.php openwrt官网地址:https://openwrt.org/zh-cn/doc/howto/buil ...

  9. 【转】ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

    为了加强安全性,MySQL5.7为root用户随机生成了一个密码,在error log中,关于error log的位置,如果安装的是RPM包,则默认是/var/log/mysqld.log. 一般可通 ...

  10. 项目之socket

    客户端socket 客户端套接字完成的任务很统一,发送请求,接收请求结果 可以封装成一个方法 使用的tcp协议存在粘包问题,故需要自定义报头 import json import struct #项目 ...