文件(夹)操作

对文件和文件夹操作的类

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

 

 

posted @ 2018-01-21 08:03  奔跑的蒲公英  阅读(110)  评论(0编辑  收藏  举报