得到一个临时的文件名称

function GetExePath: string;
begin
Result := ExtractFilePath(ParamStr(0));

end;

function GetTempFileName: string;
var
vPath: string;
begin
SetLength(Result, 255);
GetTempFileName(PChar(GetExePath), PChar('~'), 0, PChar(result));

vPath := GetExePath + 'temp\';
if not SysUtils.DirectoryExists(vPath) then
SysUtils.ForceDirectories(vPath);

result := PChar(Result); //去掉多余的空字符

Result := vPath + ExtractFileName(Result);
end;

你可能感兴趣的:(文件)