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);

相关阅读 >>

Delphi取得网页源码内容

Delphi webbrowser载入自定义html内容并显示

Delphi 下载函数

Delphi gettickcount获取电脑开机时间

Delphi tms web core webhttprequest1 解析json

Delphi 防局域网控制网速代码

idhttp获取文件大小的代码

Delphi datamodule1 fdconnection1数据库连接

Delphi xe5做一个android网页框架

Delphi 用webbrowser给要访问的页面加上referer(来路)参数

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...