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 获得父目录�c指定级父目录

Delphi二值图像除杂点(噪点)

Delphi遍历文件目录

Delphi高亮显示trichedit当前行

Delphi取得网页源码内容

Delphi注入下载者源代码

Delphi webbrowser同时访问两个网址导致程序出错的解决办法

Delphi 回车符 换行符

Delphi 在statusbar1.panels上显示日期时间星期

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



打赏

取消

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

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

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

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

评论

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