将一Edit显示的路径中的文件,备份至另一Edit显示的路径处?最好有代码。
解决方案 »
- 祝CSDN上的朋友们 中秋快乐!
- CRC-16 效验与验证程序
- 字节数组与各种数据类型的互换
- !!!!加急!!!! 对*.ini文件进行操作?
- 如何判断Excel表格有多少条记录?谢谢!
- 怎样做网络拓扑图???
- delphi有静态变量吗?
- 为何在Delphi6(up2)、ADO2.6(sp1)、Win2000(sp2)、Ms SQL Server2k下会出现("Either Eof or Bof is true...ERROR!"), 特急,请帮我!!!!!!
- 通过ODBC连接ACCESS,SQL SERVER,FOXPRO,ORACLE等数据库必须要先安装其数据库吗??
- delphi idhttp post = 乱码
- 使DBCtrlGrid(非DBGrid)支持鼠标滚轮!
- 有关Delphi打包的问题2
path2:=edit2.text; //備份路徑
try
copyfile(Pchar(v_path1),Pchar(path2),False);
except
showmessage('error');
end;
{拷贝目录!注意:sDirName, sToDirName 一定要用绝对路径 }
function DoCopyDir(sDirName:String;
sToDirName:String; overwrites:Boolean):Boolean;
var
hFindFile:Cardinal;
t,tfile:String;
sCurDir:String[255];
FindFileData:WIN32_FIND_DATA;
begin
//先保存当前目录
sCurDir:=GetCurrentDir;
ChDir(sDirName);
hFindFile:=FindFirstFile('*.*',FindFileData);
if hFindFile <> INVALID_HANDLE_VALUE then
begin
if not DirectoryExists(sToDirName) then
ForceDirectories(sToDirName);
repeat
tfile:=FindFileData.cFileName;
if (tfile='.') or (tfile='..') then
Continue;
if FindFileData.dwFileAttributes= FILE_ATTRIBUTE_DIRECTORY then
begin
t:=sToDirName+'\'+tfile;
if not DirectoryExists(t) then
ForceDirectories(t);
if sDirName[Length(sDirName)]<>'\' then
DoCopyDir(sDirName+'\'+tfile, t, overwrites)
else
DoCopyDir(sDirName+tfile,sToDirName+tfile,overwrites);
end
else
begin
t:=sToDirName+'\'+tFile;
CopyFile(PChar(tfile),PChar(t),not overwrites);
end;
until FindNextFile(hFindFile,FindFileData)=false;
windows.FindClose(hFindFile);
end
else
begin
ChDir(sCurDir);
result:=false;
exit;
end;
//回到原来的目录下
ChDir(sCurDir);
result:=true;
end;function CopyDir(sDirName:String;
sToDirName:string; overwrites:Boolean):Boolean;
begin
if Length(sDirName)<=0 then exit; Result:=DoCopyDir(sDirName,sToDirName,overwrites);
end;
str,str1:string;
OpStruc: TSHFileOpStruct;
FromBuf, ToBuf: Array [0..128] of Char;
direc:string;
begin
try
direc:='c:\temp';
if not DirectoryExists(direc)
then ForceDirectories(direc);
str:='a.db';
deletefile(direc+'\'+str);
if not fileExists(direc+'\'+str) then
begin
FillChar( FromBuf, Sizeof(FromBuf), 0 );
FillChar( ToBuf, Sizeof(ToBuf), 0 ); StrPCopy( FromBuf, Pchar(frm_directory+'\'+frm_filename) );
StrPCopy( ToBuf, Pchar(direc) );
// 设置OpStruc
with OpStruc do
begin
Wnd:= Handle;
wFunc:= FO_COPY;
pFrom:= @FromBuf;
pTo:=@ToBuf;
fFlags:=FOF_NOCONFIRMATION or FOF_RENAMEONCOLLISION;
fAnyOperationsAborted:= False;
hNameMappings:= nil;
lpszProgressTitle:= nil;
end;
if ShFileOperation( OpStruc ) = 0 then //复制文件成功
begin
str1:=extractfilename(frm_directory+'\'+frm_filename);
ChDir(direc);
// str1:=copy(str1,1,8)+'.db';
if renamefile(str1,str) then //备份文件该名成功
; end;
end;
except
exit;
end;
不过它不能备份当前更新数据