他的問題:"當我按button8時,如果2個目錄的內容完全一樣時,內存就會加大...."procedure TForm1.Button8Click(Sender: TObject);
begin
if (LabeledEdit1.Text<>'') and (LabeledEdit2.Text<>'') then
begin
listview1.Items.Clear;
CompDir(LabeledEdit1.Text,LabeledEdit2.Text,True,True,True,True,True,False,False);
showmessage('^^ 遊戲巳更新完畢!!!')
end
else
showmessage('請在左邊選擇遊戲名稱!!');
end;
begin
if (LabeledEdit1.Text<>'') and (LabeledEdit2.Text<>'') then
begin
listview1.Items.Clear;
CompDir(LabeledEdit1.Text,LabeledEdit2.Text,True,True,True,True,True,False,False);
showmessage('^^ 遊戲巳更新完畢!!!')
end
else
showmessage('請在左邊選擇遊戲名稱!!');
end;
解决方案 »
- delphi登录窗口的问题~!
- 请问grid里怎么操作dbf或是mdb,还有小弟是初学,有什么进步快的方法。
- 请问:ACCESS数据库导入到ORACLE中的最佳解决办法???
- 一个小问题
- 关于★★★★★公布ERP源程序(代码+数据库)★★★★★
- 如何在listView中的一个Cell里即显示文字也显示图形?
- 大家去http://www.csdn.net/Expert/topic/519/519545.shtm领分啊
- 如何关闭WIN系统!
- 急急急!关于三层结构的几个基本问题,我们正在确定一个方案,请高手赐教!!一定给分!
- 错误类EComponentError和错误类EAccessViolation的弹出,麻烦各位大神看下我的问题
- 请教BDE的api数据库查询问题
- 为何这样不行
var Rec: TSearchRec;
begin
if Dir[Length(Dir)] <> '\' then
Dir:= Dir + '\';
if FindFirst(Dir + '*.*', faAnyFile, Rec) = 0 then
repeat
if (Rec.Name <> '.') and (Rec.Name <> '..') then
if Rec.Attr and faDirectory > 0 then
DeleteTree(Dir + Rec.Name)
else
DeleteFile(Dir + Rec.Name);
until FindNext(Rec) <> 0;
FindClose(Rec);
RemoveDir(Dir);
end;
var //Path1,Path2為源路徑和目標路徑 Types為更新路徑類型(單個文件faAnyFile,文件夾faDirectory)
SResult : integer;
SearchRec : TSearchRec;
begin FindClose(SearchRec);
Screen.Cursor:=crAppStart;
Application.ProcessMessages;
result:=True; if Types=faAnyFile then
begin
statusbar1.panels[0].text:='正在更新比較:'+Path2; //狀態欄顯示正在更新的文件
FileSetAttr(Path2, 0);
DeleteFile (Path2);
if copyfile(pchar(string(Path1)),pchar(string(Path2)),True) then
result:=True
else
result:=False;
Screen.Cursor:=crDefault;
exit;
end; if Types=faDirectory then
begin if Path1[length(path1)]<>'\' then
Path1:=pchar(Trim(Path1)+'\')
else
Path1:=pchar(Trim(Path1));
if Path2[length(path2)]<>'\' then
Path2:=pchar(Trim(Path2)+'\')
else
Path2:=pchar(Trim(Path2)); if ForceDirectories(pchar(string(Path2))) then
result:=True
else
begin
result:=False;
Screen.Cursor:=crDefault;
exit;
end; SResult:=Findfirst(path1+'*.*',faAnyFile-faDirectory,SearchRec);
while(SResult=0) do
begin
statusbar1.panels[0].text:='正在更新比較:'+Path2+SearchRec.Name; //狀態欄顯示正在更新的文件
if not copyfile(pchar(string(Path1+SearchRec.Name)),pchar(string(Path2+SearchRec.Name)),True) then
result:=False;
SResult:=Findnext(SearchRec);
end;
FindClose(SearchRec);
SResult:=Findfirst(path1+'*.*',faAnyFile,SearchRec);
while (SResult=0) do
begin
if (DirectoryExists(Path1+SearchRec.name)) and (SearchRec.name <> '.') and (SearchRec.name <> '..') then
begin
UpdataFile(Path1+SearchRec.name,Path2+SearchRec.name,faDirectory);
end;
SResult:=Findnext(SearchRec);
end;
FindClose(SearchRec);
Screen.Cursor:=crDefault;
exit;
end; FindClose(SearchRec);
Screen.Cursor:=crDefault;
end;
//Path1,Path2為指定比較的目錄Recursive是否要進行目錄遞歸CompSize為是否進行文件大小比較 TripComp是否對Path1,Path2雙向比較 TripUpdata是對path1和path2雙向更新AutoUpdata為自動更新OnlyFolder為選擇僅對目錄進行比較AnswerAll為逐條提示用戶進行更新
var
SResult:integer;
SearchRec:TSearchRec;
SearchRecTemp:TSearchRec;
ResultMsgbox:integer;
begin
FindClose(SearchRec);
FindClose(SearchRecTemp);
Screen.Cursor:=crAppStart;
Application.ProcessMessages; if Path1[length(path1)]<>'\' then
Path1:=pchar(Trim(Path1)+'\')
else
Path1:=pchar(Trim(Path1));
if Path2[length(path2)]<>'\' then
Path2:=pchar(Trim(Path2)+'\')
else
Path2:=pchar(Trim(Path2)); if not (DirectoryExists(path1)) then
begin
Screen.Cursor:=crDefault;
showmessage('遠端目錄無效');
exit;
end; if not (DirectoryExists(path2)) then
begin
Screen.Cursor:=crDefault;
ForceDirectories(path2);
end; if not OnlyFolder then ///文件比較開始
begin
SResult := FindFirst(Path1 + '*.*', faAnyFile - faDirectory, SearchRec);
while (SResult = 0) do
begin
if CompSize and (FindFirst(Path2 + SearchRec.name, faAnyFile - faDirectory, SearchRecTemp)=0) then
begin //////////{文件大小不相等 只進行正向更新}
if SearchRec.Size<>SearchRecTemp.size then
begin
with listview1.Items.Add do
begin
caption := '大小(正向)';
subitems.Add(Path1+SearchRec.name+' (Size: '+inttostr(SearchRec.Size)+'Bytes)');
subitems.Add(Path2+SearchRecTemp.name+' (Size: '+inttostr(SearchRecTemp.Size)+'Bytes)');
if (not AutoUpdata) and (not AnswerAll) then
subitems.Add('未更新')
else
begin
if AutoUpdata then
begin
if ShowMsg then
begin
ResultMsgbox:=application.MessageBox(Pchar('程式對大小不同的檔會全部進行正向更新,更新前是否備份?'),Pchar('比較更新提示'),MB_YESNOCANCEL); if ResultMsgbox=mrCancel then
begin
AutoUpdata:=False;
ShowMsg:=False;
subitems.Add('用戶中止!');
exit;
end; if ResultMsgbox=mrNo then
begin
AnswerAll:=False;
ShowMsg:=False;
if UpdataFile(Path1+SearchRec.name,Path2+SearchRecTemp.name,faanyfile) then
subitems.Add('更新成功!')
else
subitems.Add('更新出錯!');
end; if ResultMsgbox=mrYes then
begin
AnswerAll:=False;
ShowMsg:=False;
if UpdataFile(Path1+SearchRec.name,Path2+SearchRecTemp.name,faanyfile) then
subitems.Add('更新成功!')
else
subitems.Add('更新出錯!');
end; end else //否則進入不確認全部更新
if UpdataFile(Path1+SearchRec.name,Path2+SearchRecTemp.name,faanyfile) then
subitems.Add('更新成功!')
else
subitems.Add('更新出錯!');
end; if AnswerAll and (ResultMsgbox<>mrCancel) and (not AutoUpdata) then
begin
ResultMsgbox:=application.MessageBox(Pchar('程式對大小不同的檔將進行正向更新?'),Pchar('比較更新提示'),MB_YESNOCANCEL);
if ResultMsgbox=mrCancel then
begin
AnswerAll:=False;
subitems.Add('用戶中止!');
exit;
end; if ResultMsgbox=mrNo then
begin
AnswerAll:=True;
subitems.Add('用戶取消!');
end; if ResultMsgbox=mrYes then
begin
if UpdataFile(Path1+SearchRec.name,Path2+SearchRecTemp.name,faanyfile) then
subitems.Add('更新成功!')
else
subitems.Add('更新出錯!');
end;
end;
end;
end;
end;
end;