asp教程.net c#创建的数据文件进行读取
<% @ webhandler language="c#" class="averagehandler" %>
using system;
using system.web;public class averagehandler : ihttphandler
{
public bool isreusable
{ get { return true; } }
public void processrequest(httpcontext ctx)
{
ctx.response.write("hello");
}
}
cs文件
using system.web
public sealed class textbuilder : ihttphandler
{
public void processrequest(httpcontext context)
{
context.response.clearcontent();
context.response.contenttype = "text/plain";
context.response.write("hello world");
context.response.end();
}
public bool isreusable
{
get { return true; }
}
}
方法二
binarywriter 和 binaryreader 类用于读取和写入数据,而不是字符串。下面的代码示例示范了向新的、空文件流 (test.data) 写入数据及从该文件读取数据。在当前目录中创建了数据文件之后,也就同时创建了相关的 binarywriter 和 binaryreader,binarywriter 用于向 test.data 写入整数 0 到 10,test.data 在文件尾留下了一个文件指针。在将文件指针设置回初始位置后,binaryreader 读出指定的内容。
[c#]
using system;
using system.io;
class mystream {
private const string file_name = "test.data";
public static void main(string[] args) {
// create the new, empty data file.
if (file.exists(file_name)) {
console.writeline("{0} already exists!", file_name);
return;
}
filestream fs = new filestream(file_name, filemode.createnew);
// create the writer for data.
binarywriter w = new binarywriter(fs);
// write data to test.data.
for (int i = 0; i < 11; i++) {
w.write( (int) i);
}
w.close();
fs.close();
// create the reader for data.
fs = new filestream(file_name, filemode.open, fileaccess.read);
binaryreader r = new binaryreader(fs);
// read data from test.data.
for (int i = 0; i < 11; i++) {
console.writeline(r.readint32());
w.close();
}
}
}
如果 test.data 已存在于当前目录中,则引发一个 ioexception。始终使用 filemode.create 创建新文件,而不引发 ioexception。
方法四
using system.web
public sealed class textbuilder : ihttphandler
{
public void processrequest(httpcontext context)
{
context.response.clearcontent();
context.response.contenttype = "text/plain";
context.response.write("hello world");
context.response.end();
}
public bool isreusable
{
get { return true; }
}
}
茶杯头甜蜜终章dlc 官方手机版v1.0.0.3
下载火柴人传说暗影格斗内置菜单 最新版v3.0.1
下载荒野乱斗测试服 安卓版v61.10.3
下载荒野乱斗彩虹服 安卓版v61.10.3
下载寒霜启示录 安卓版v1.25.10
寒霜启示录是一款生存模拟游戏,不少玩家可能对于末日都有着自己
末日城堡免广告版 安卓最新版v0.7.1
末日城堡免广告版是一款非常好玩的模拟经营类游戏,内部可以不看
甜蜜人生模拟器 最新版v1.4.5
甜蜜人生模拟器是一款非常好玩的模拟恋爱手游,玩家在这里能够对
武器锻造师内置功能菜单 v10.4
武器锻造师内置菜单版是游戏的破解版本,在该版本中为玩家提供了
开放空间overfield 安卓版v1.0.5
开放空间Overfield是一款箱庭养成经营手游,让你在广阔