文件操作类的一些方法

 

BinaryReader类——从文件流中读取二进制文件

构造函数:BinaryReader()  重载,实例化一个 BinaryReader 对象

方法:

   Close(),关闭当前 reader 和潜在的流

   Dispose(),释放被 BinaryReader 使用的未托管的资源,并选择性的释放托管资源

   Equals(),判断指定对象是否和当前对象相等

   FillBuffer(),用一个从流中读取的制定数量的字节来填充内在缓冲区

   Finalize(), 在对象被回收机制回收资源之前,允许该对象尝试释放资源和执行其他清除操作

   GetHashCode(), 作为一个 hash 函数为制定类型提供服务

   GetType(), 得到当前实例的类型

   MemberwiseClone(), 为当前对象创建一个浅拷贝

   PeekChar(), 返回下一个可用的字符,并且不前景字符或字节的位置

   Read(), 重载,从潜在的流中读取字符,并且移动当前流的位置

属性:BaseStream   访问潜在二进制流

 

 

BinaryWriter类——将二进制流写入文件中

Reader 类相似,方法稍微少了点。

 

 

用法:

一般都是先用FileStream 定义一个文件流对象,然后再用 BinaryReader BinaryWriter 对文件进行读写。


 

 

 

Directory

  Exposes static methods for creating, moving, and enumerating through directories and subdirectories. This class cannot be inherited.

 

  提供一些静态方法来创建,移动 并且列举目录和子目录。类不能够被继承。


 

File

  Provides static methods for the creation, copying, deletion, moving, and opening of files, and aids in the creation of  FileStream  objects.

  提供一系列静态方法来创建、拷贝、删除、移动和打开创建的文件,并且帮助文件流对象的创建。

 

 

DirectoryInfo

  Exposes instance methods for creating, moving, and enumerating through directories and subdirectories. This class cannot be inherited.

  提供实例化方法来创建,移动,列举目录和子目录,该类不能被继承。

基本的方法:

Create(),

CreateSubdirectory(),

Move(),

GetDirectories(),

GetFiles(),

 

 

 

 

FileInfo

 

Provides instance methods for the creation, copying, deletion, moving, and opening of files, and aids in the creation of  FileStream  objects. This class cannot be inherited .

提供一些实例化方法来创建,拷贝,删除,移动和打开文件,并且为文件流的创建提供帮助。不能够被继承。

基本的方法:

Create(),

Delete(),

Copy(),

Open(),

Move()

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值