首页 > 其他 > 详细

文件(夹)操作

时间:2018-01-21 10:45:43      阅读:190      评论:0      收藏:0      [点我收藏+]

对文件和文件夹操作的类

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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!