delphi中怎样替换整个项目中的某个字符串?
因为有N个文件中包含需要替换的字符串,如果逐个替换太麻烦了,请问有没有简单的方法?
[解决办法]
把这个字符串变成一个全局变量,替换的时候只需要替换这个字符串的赋值就可以了。
可以用Replace
[解决办法]
[解决办法]
如果主是非必此功能置入自己程序的。直接DOWN一百K的批量文本替工具,比省事,
[解决办法]
DELPHI中不提供这样的编辑功能,可以自己写个工具,查找替换就可以了。
[解决办法]
写代码自己检索pas文、窗体文件替换,以为又是宏的处理问题。
[解决办法]
首先使用
- Delphi(Pascal) code
function FindFile(Path: string): string; {搜索文件夹和文件}var Sr: TSearchRec; CommaList: TStringList; s: string; dt: TDateTime;begin commalist := Tstringlist.Create; try Findfirst(path + '*.*', faAnyFile, sr); if ((Sr.Attr and faDirectory) > 0) and (Sr.Name <> '.') then begin dt := FileDateToDateTime(sr.Time); s := FormatDateTime('yyyy-mm-dd hh:nn', dt); commalist.add('*' + s + sr.name); end; while findnext(sr) = 0 do begin if ((Sr.Attr and faDirectory) > 0) and (Sr.Name <> '..') then begin dt := FileDateToDateTime(sr.Time); s := FormatDateTime('yyyy-mm-dd hh:nn', dt); commalist.add('*' + s + sr.name); end; end; FindClose(sr); FindFirst(path + '*.txt', faArchive + faReadOnly + faHidden + faSysFile, Sr); if Sr.Attr <> faDirectory then begin dt := FileDateToDateTime(sr.Time); s := FormatDateTime('yyyy-mm-dd hh:nn', dt); commalist.add('\' + s+ Format('%.0n', [sr.Size / 1]) + '|' + sr.name); end; //Inttostr( while findnext(sr) = 0 do begin if (sr.Attr <> faDirectory) then begin dt := FileDateToDateTime(sr.Time); s := FormatDateTime('yyyy-mm-dd hh:nn', dt); commalist.add('\' + s +Format('%.0n', [sr.Size / 1]) + '|' + sr.name); end; end; FindClose(Sr); except end; Result := commalist.Text; //Result是消息的 定义 commalist.Free;end;
[解决办法]
cnpack
[解决办法]
安装一个untraedit,它可以在某目录下,替换所有某一类型文件的
[解决办法]
[解决办法]
以前自己写个一个这方面的小软件,LZ可以自己写的一个啊,思路无非是遍历文件夹然后搜索替换...