c# 二进制读写
来源:互联网 发布:手机免费听歌软件 编辑:程序博客网 时间:2024/04/26 06:53
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();
}
}
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();
}
}
- c#读写二进制
- c# 二进制读写
- c# 二进制读写
- C#二进制文本的读写
- C#按二进制模式读写文件
- C# 二进制字节流读写封装
- 二进制读写
- C# 二进制读写与序列化和反序列化
- 读写二进制字段数据
- 二进制读写图片操作
- 二进制流读写
- python 二进制读写
- c/c++二进制读写
- ado 读写二进制数据
- Java读写二进制数据
- MySQL 二进制读写语句
- 读写二进制file
- sqlite3 读写二进制数据
- JSTL JSP标准标签库(四)
- 关于l ibrary not found for -lz.1.2.3 编译错误
- bzip2压缩实例
- 媒体查询:支持不同的视口
- 自己使用Fedora18过程中,一些问题解决备忘!
- c# 二进制读写
- POJ 3592 Instantaneous Transference
- DB2 表空间之SMS、DMS
- IOS自动释放池
- Android之编辑框(EditText)控件
- C++ 程序执行过程
- 对象分析方法
- 如何做一款成功的应用(上)
- error LNK1123: 转换到 COFF 期间失败: 文件无效或损坏