函数一 //---------------add--2002-03-10---sunfx { function searchfolder 搜索文件夹是否存在 } function Tyeargzreportfrm.searchfolder(var foldername:string):boolean; var path:string; sr: TSearchRec; begin path:=ExtractFilePath(Application.ExeName)+'report\'+foldername; if FindFirst(path, faAnyFile, sr) = 0 then begin if ((sr.Attr and fadirectory) = fadirectory) and (sr.Name<>'.') and (sr.Name<>'..') then begin result:=true; end; end //first else result:=false; FindClose(SR); end;
if not directoryexists(bfdatapath) then ForceDirectories(bfdatapath);判断文件夹(目录)是否存在!不存在创建!if not fileexists(bfdatapath + newdatafile) then CopyFile(PChar(extractfilepath(application.exename) + filename), PChar(bfdatapath + newfilename), true );判断文件newdatafile是否存在!不存在则将extractfilepath(application.exename)目录下的文件filename复制到bfdatapath目录下,以newfilename命名!!
//---------------add--2002-03-10---sunfx
{
function searchfolder
搜索文件夹是否存在
}
function Tyeargzreportfrm.searchfolder(var foldername:string):boolean;
var
path:string;
sr: TSearchRec;
begin
path:=ExtractFilePath(Application.ExeName)+'report\'+foldername;
if FindFirst(path, faAnyFile, sr) = 0 then
begin
if ((sr.Attr and fadirectory) = fadirectory) and (sr.Name<>'.') and (sr.Name<>'..') then
begin
result:=true;
end;
end //first
else
result:=false;
FindClose(SR);
end;
{
if(fileOut.Open(以独享方式打开))
{
//操作文件
};
}拷贝文件CopyFile
if copyfile('c:\123.dbf','c:\456.dbf',false) then showmessage('ok')
使用 sysutil.copy ();
判断 文件夹也就是目录是否存在 :应该是有个专门的函数,就象fileexists 一样具体你自己找找!~~~
ForceDirectories(bfdatapath);判断文件夹(目录)是否存在!不存在创建!if not fileexists(bfdatapath + newdatafile) then
CopyFile(PChar(extractfilepath(application.exename) + filename),
PChar(bfdatapath + newfilename),
true );判断文件newdatafile是否存在!不存在则将extractfilepath(application.exename)目录下的文件filename复制到bfdatapath目录下,以newfilename命名!!