delphi 部分操作文件函数  
官方Delphi 学习QQ群: 682628230(三千人)\n
频道

delphi 部分操作文件函数


delphi 部分操作文件函数

1、返回文件扩展名
function ExtractFileExt(const FileName: ): ;

2、返回文件名
function ExtractFileName(const FileName: ): ;
返回应用文件名
function ExtractFileName(ParamStr(0)): ;
返回应用路径
function ExtractFilePath(ParamStr(0)): ;

3、检测文件是否存在
function FileExists: Boolean;

4、查找目录中是否存在某文件
function FileSearch(const Name, DirList: ): ;

5、返回路径名
function ExpandFileName(const FileName: ): ;

6、返回文件大小
function FileSize(var F): Integer;

7、返回上上次I/O操作状态
function IOResult: Integer;

8、返回文件属性
function FileGetAttr(const FileName: ): Integer;

9、设置文件属性
function FileSetAttr(const FileName: ; Attr: Integer): Integer;

10、设置文件DOS日期戳
On Windows:
function FileSetDate(Handle: Integer; Age: Integer): Integer; overload;

Cross-platform:
function FileSetDate(const FileName: ; Age: Integer): Integer; overload;

11、返回文件DOS日期戳
function FileGetDate(Handle: Integer): Integer;

12、把Delphi日期格式转化为DOS日期格式
function DateTimeToFileDate(DateTime: TDateTime): Integer;

13、把DOS日期格式转化为Delphi日期格式
function FileDateToDateTime(FileDate: Integer): TDateTime;

14、 修改文件扩展名
function ChangeFileExt(const FileName, Extension: ): ;

15、删除文件
function DeleteFile(const FileName: ): Boolean; (SysUtils)

16、打开文件
function FileOpen(const FileName: ; Mode: LongWord): Integer;(SysUtils)返回为文件句柄
打开模式:fmOpenRead fmOpenWrite fmOpenReadWrite fmShareCompat fmShareExclusive fmShareDenyWrite fmShareDenyRead fmShareDenyNone

17、把光标定位到某点
function FileSeek(Handle, Off, Origin: Integer): Integer; overload;
function FileSeek(Handle: Integer; const Off: Int64; Origin: Integer): Int64; overload;

Off为偏移量

Origin为开始模式
Origin Action

0 The file poer is positioned Off s from the beginning of the file.
1 The file poer is positioned Off s from its current position.
2 The file poer is positioned Off s from the end of the file.

18、把文件读到缓冲区
function FileRead(Handle: Integer; var Buffer; Count: Integer): Integer;

19、关闭文件
procedure FileClose(Handle: Integer);

推荐分享
图文皆来源于网络,内容仅做公益性分享,版权归原作者所有,如有侵权请告知删除!
 

Copyright © 2014 DelphiW.com 开发 源码 文档 技巧 All Rights Reserved
晋ICP备14006235号-8 晋公网安备 14108102000087号

执行时间: 0.046517133712769 seconds