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);
}
}
net8:文本文件的创建及其读写的更多相关文章
- C# 对文本文件的几种读写方法总结
计算机在最初只支持ASCII编码,但是后来为了支持其他语言中的字符(比如汉字)以及一些特殊字符(比如€),就引入了Unicode字符集.基于Unicode字符集的编码方式有很多,比如UTF-7.UTF ...
- 消息队列的创建与读写ftok,msgget,msgsnd,msgrcv,指令ipcs,ipcrm 查看,删除消息队列
ipcs是Linux下显示进程间通信设施状态的工具.可以显示消息队列.共享内存和信号量的信息.对于程序员非常有用,普通的系统管理员一般用不到此指令. ipcs -q 查看系统使用的IPC队列资源 ip ...
- C#创建、读写、增加、删除XML操作
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threa ...
- 【aardio】]SQL创建、读写 excel
import access; var db,err = access( "/test.xls" ) //文件不存在可自动创建 //创建表 if( ! db.existsTable( ...
- Java之文本文件的创建和读取(含IO流操作)
工具类:对文件的读取,创建.直接复制拿来用! package cn.zyzpp.util; import java.io.BufferedReader; import java.io.Buffered ...
- C#创建cookie读写cookie
一.创建cookie HttpCookie cookie = new HttpCookie("UserInfo");//创建多值cookie cookie ...
- 管道的创建与读写pipe
1.管道的创建 #include <unistd.h> int pipe(int pipefd[2]); linux下创建管道可以通过函数pipe来完成.该函数如果调用成功,数组中将包含两 ...
- WinForm 创建与读写配置文件
(转自:http://www.cnblogs.com/SkySoot/archive/2012/02/08/2342941.html) 1. 创建 app.config 文件: 右击项目名称,选择“添 ...
- Linux学习之路4——文件IO打开、创建、读写操作
1.使用man 2 open.man 2 creat.man 2 write.man 2 read命令获取头文件 语法: int open(const char *pathname, int flag ...
随机推荐
- Ubuntu 16.04下Java环境安装与配置
首先下载linux下的安装包 登陆网址https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.h ...
- C-基础:详解sizeof和strlen,以及strstr
sizeof和strlen (string.h) 先看几个例子(sizeof和strlen之间的区别): (1) 对于一个指针, char* ss ="0123456789"; ...
- [POJ] 2411 Mondriaan's Dream
Mondriaan's Dream Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 18903 Accepted: 10779 D ...
- nxlog安装配置
Nxlog安装配置文档 任 帅 1.安装nxlog,全部默认即可. 如果拷贝直接安装,没有拷贝可以下载.下载链接: https://nxlog.co/system/files/products ...
- DateFormat的format()方法线程不安全的问题分析
最近看到<侦探剧场:堆内存神秘溢出事件>https://my.oschina.net/u/2368090/blog/1628720,于是自己也想测试了解一下DateFormat的多线程安全 ...
- fsm三种建模思路比较
==================================================================================================== ...
- 解决zend studio代码无法自动提示的3个方法
最近电脑重装,索性把用了好多年的老版本7.x 升级了,网上下载了一个12.x的破解版. 起初一切正常,等导入项目开始开发的时候发现PHP函数尽然没有提示,一脸懵逼! 经过多方查阅和尝试,现在分享3个解 ...
- laravel 设计思想简单了解
服务容器 laravel框架中 服务容器是整个系统功能调度配置的核心,在系统运行过程中动态的为系统提供需要的服务 从而实现了解耦 控制反转(IOC) 控制反转是一种设计模式 主要解决了系统组件之间的相 ...
- VS搭建一个WEB的简历第二天,,,最终目标写个好看的简历,再搭建一个自己脑海的网页
VS做简历的第二天 第二天吸取了第一天的教训写的代码 第一天写的代码https://www.cnblogs.com/pythonywy/p/10816215.html,写了一堆错误T T 非常感谢Li ...
- python--基础数据类型的补充与深浅copy
一 . join的用法 lst =['吴彦祖','谢霆锋','刘德华'] s = '_'.join(lst) print(s) # 吴彦祖_谢霆锋_刘德华 # join() "*" ...