delphi 判断文件路径,不存在则建立


本文整理自网络,侵删。

  procedure TForm1.Act_CheckPath(FilePath:String);
var
MyFile:String;
i:Integer;
FileDir,TemStr:WideString;
PosList,DirList:TStrings;
begin
PosList:=TStringList.Create;
DirList:=TStringList.Create;
MyFile:=FilePath+'\';
FileDir:=MyFile;
//记录'\'的位置;
for i:=1 to Length(FileDir) do
begin
TemStr:=Copy(FileDir,i,1);
if TemStr = '\' then
PosList.Add(IntToStr(i));
end;
for i:=0 to PosList.Count - 1 do
begin
DirList.Add(Copy(FileDir,1,StrToInt(PosList.Strings[i])-1));
end;
for i:=0 to DirList.Count -1 do
begin
//判断文件路径是否存在
if not DirectoryExists(DirList.Strings[i]) then
//不存在,则建立新路径
CreateDir(DirList.Strings[i]);
end;
PosList.Free;
DirList.Free;
end;

相关阅读 >>

Delphi setwindowshookex - 设置钩子 unhookwindowshookex - 卸掉钩子

Delphi thttprio 控件调用webservice超时问题

Delphi xe 跨平台(windows、android安卓、苹果macos、苹果ios)写法

Delphi获得唯一id字符串

Delphi 创建圆形或椭圆形窗体

Delphi 单元文件结构

Delphi 泛型排序器 tcomparer

Delphi 获取按键键值

Delphi inc () 计数用法

Delphi 一个call应该如何写?

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



打赏

取消

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

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

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

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

评论

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