文件(夹)操作

对文件和文件夹操作的类

1.FileInfo 具体文件,使用此类的对象,可以获得问价大小等各种信息 继承自FileSystemInfo

建立对象,FileInfo Fi= new FileInfo();

常用属性

·         Name 文件名称

·         Extension 文件扩展名

·         FullName 文件完全路径(物理路径)

·         Length 文件大小,单位为字节

·         CreationTime 文件创建时间

·         LastAccesTime 文件上次访问时间

·         LastWriteTime 文件上次修改时间

·         DirectoryName 所在的文件夹

·         Attributes 文件属性,如只读,隐藏等

2.File 提供static方法,文件新建、复制、移动和删除

·         Create(filePath)

·         Copy(filePath1,filePath2)

·         Move(filePath1,filePate2)

·         Delete(filePath)

·         Exists(filePath)

·         CreateText(filePath)

3.DirectoryInfo 具体文件夹,使用此类的对象可以获得文件夹大小等各种信息 继承自FileSystemInfo

建立对象 DirectoryInfo Di = new DirectoryInfo ();

常用属性

·         Name 文件夹名称

·         FullName 文件夹完全路径(物理路径)

·         CreationTime 文件夹创建时间

·         LastAccessTime 文件夹上次访问时间

·         LastWriteTime 文件夹上次修改时间

·         Parent 父文件夹

·         Root 所在根目录

4.Directory 提供static方法,文件夹的新建、移动和删除

·         CreateDirectory(Dirpath)

·         Move(DirPth1,DirPath2)

·         Delete(Dirpath)

·         Exists(DirPath)

·         GetDirectories(DirPath) 获取子文件夹

·         GetFiles(DirPath) 获取子文件

 

5.Path 文件路径,提供路径处理

·         Combine

·         GetDirectoryName

·         GetExtension

·         GetFileName

·         GetFileNameWithoutExtension

·         GetFullPath

·         GetPathRoot

·         GetTempFileName

·         GetTempPath

 

 

转载于:https://www.cnblogs.com/pugongying123/p/8323427.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值