码迷,mamicode.com
首页 > Windows程序 > 详细

delphi 删除目录和创建目录,临时文件夹

时间:2015-07-13 15:50:10      阅读:207      评论:0      收藏:0      [点我收藏+]

标签:

获取用户当前的Windows临时文件夹
function GetWinTempPath: string;
var
TempDir: array[0..255] of char;
begin
GetTempPath(255, @TempDir);
Result := strPas(TempDir);
end;

删除目录:(目录里有东西也一样删)(shellapi)

function DelDirectory(const Source: string): boolean;
var
fo: TSHFILEOPSTRUCT;
begin
FillChar(fo, SizeOf(fo), 0);
with fo do
begin
    Wnd := 0;
    wFunc := FO_DELETE;
    pFrom := PChar(source + #0);
    pTo := #0#0;
    fFlags := FOF_NOCONFIRMATION + FOF_SILENT;
end;
Result := (SHFileOperation(fo) = 0);
end;

创建目录和设置目录属性
var
iFileAttrs: Word;

iFileAttrs := faSysFile + faHidden;
ForceDirectories(ExtractFilePath(Application.Exename) + ‘temp\‘);//如存在目录就不创建.
FileSetAttr(ExtractFilePath(Application.Exename) + ‘temp\‘, iFileAttrs);

delphi 删除目录和创建目录,临时文件夹

标签:

原文地址:http://www.cnblogs.com/FKdelphi/p/4642985.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!