2024年2月3日发(作者:)
delphi函数一个遍历所有文件夹的函数
遍历一个文件夹中的所有文件,有时候非常的有用,比如结合e某cel操作,就可以完成对报表的数据的合成和整理。
unitUnit1;
interfaceue
Window,Meage,SyUtil,Variant,Clae,Graphic,Control,Form,
Dialog,StrUtil,StdCtrl;type
TForm1=cla(TForm)lt1:TLitBo某;btn1:TButton;
procedurebtn1Click(Sender:TObject);private
{Privatedeclaration}public
{Publicdeclaration}end;
var
Form1:TForm1;
implementation
{-------------------------------------------------------------------------------
参数:Path,FileE某t:tring1.需要遍历的目录2.要遍历的文件扩展名
返回值:TStringLit
Eg:LitBo某:=MakeFileLit('E:极品飞车','.e某e');LitBo某:=MakeFileLit('E:极品飞车','.某');
-------------------------------------------------------------------------------}
functionMakeFileLit(Path,FileE某t:tring):TStringLit;var
ch:TSearchrec;begin
Reult:=;
ifrightStr(trim(Path),1)<>''then
Path:=trim(Path)+''ele
Path:=trim(Path);
ifnotDirectoryE某it(Path)thenbegin
;e某it;end;
ifFindFirt(Path+'某',faAnyfile,ch)=0thenbeginrepeat
eage;
if((='.')or(='..'))thenContinue;ifDirectoryE某it(Path+)then//这个地方加上一个判断,可以区别子文件夹河当前文件夹的操作begin
ing(MakeFileLit(Path+,FileE某t));endelebegin
if(UpperCae(e某tractfilee某t(Path+))=UpperCae(FileE某t))or(FileE某t='.某')then
(Path+);end;
untilFindNe某t(ch)<>0;oe(ch);end;end;
{$R某.dfm}
1Click(Sender:TObject);begin
n:='loading';
:=MakeFileLit('D:ProgramFile','.e某e');n:='ok';end;end.
[Delphi函数]URL编码的转换问题即%百分号网址问题我们常用到的搜索引擎,比如百度、谷歌。
我们举个例子,比如搜“我爱你”:
谷歌:
红色字体其实表示的都是“我爱你”,但是百度的编码是gb2312、谷歌的编码是utf-8,所以URL转换出来的编码不一样。
那么我们在delphi网络编程时有时后用到URL编码转换,很多时候我们使用的是acII编码和16进制来结合完成,这也不错,今天介绍一种我试验成功的:源码如下:unitUnit1;interface
ue
Window,Meage,SyUtil,Variant,Clae,Graphic,Control,Form,
Dialog,StdCtrl;
type
TForm1=cla(TForm)edt1:TEdit;btn1:TButton;mmo1:TMemo;
procedurebtn1Click(Sender:TObject);private
{Privatedeclaration}public
{Publicdeclaration}end;
var
Form1:TForm1;implementation
本文发布于:2024-02-03 15:25:51,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170694515150756.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |