




已阅读5页,还剩4页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
uses FileCtrl; private Private declarations FFileName: string; /得到路径。 function GetPath: string; /获得目录名称。 function GetDirectoryName(Dir: string): string; procedure FindFiles(aPath: string); /磁盘检查 function CheckDisk(Drive: Byte; aSize: Int64): Boolean; /检查目录的大小 function CheckFileSize(aPath: string): Int64; /检查备份文件是否存在,不存在或存在按 确定 返回“真” function CheckFileExists(aFileNameString: string): Boolean; public Public declarations end;var FormBackUp: TFormBackUp; IsClickStop: Boolean = False;/按取消按钮时返回真。 DirectorySize: Int64;/文件夹大小。implementation$R *.DFMconst a1 = 系统已经完成对记录“ ; a2 = ”的备份。是否将记录“ ; a3 = ”删除? ;function TFormBackUp.GetPath: string;begin if RbAlias.Checked then begin if cbAlias.Text = then raise Exception.Create( 请选择别名。 ); Result := D:aaa + CbAlias.Text; end else if RbFlolder.Checked then Result := edPath.Text else Result := ; if Result = then raise Exception.Create( 您没有选择路径! ); if not DirectoryExists(Result) then raise Exception.CreateFmt( 文件夹 “%s”不存在。 , Result);end;function TFormBackUp.CheckFileSize(aPath: string): Int64;begin DirectorySize := 0; try Screen.Cursor := crHourGlass; FFileName := *.* ; FindFiles(aPath); Result := DirectorySize; Result := Result div 5; finally Screen.Cursor := crDefault; end;end;function TFormBackUp.GetDirectoryName(Dir: string): string;begin if DirLength(Dir) then Result := Dir + else Result := Dir;end;procedure TFormBackUp.FindFiles(aPath: string);var FSearchRec, DSearchRec: TSearchRec; FindResult: Integer; function IsDirNotation(aDirName: string): Boolean; begin Result := (aDirName = . ) or (aDirName = . ); end;begin aPath := GetDirectoryName(aPath); FindResult := FindFirst(aPath + FFileName, faAnyFile + faHidden + faSysFile + faReadOnly, FSearchRec); try while FindResult = 0 do begin DirectorySize := DirectorySize + FSearchRec.Size; FindResult := FindNext(FSearchRec); end; FindResult := FindFirst(aPath + *.* , faDirectory, DSearchRec); while FindResult = 0 do begin if (DSearchRec.Attr and faDirectory) = faDirectory) and not IsDirNotation(DSearchRec.Name) then begin FindFiles(aPath + DSearchRec.Name); /递归。 DirectorySize := DirectorySize + DSearchRec.Size; end; FindResult := FindNext(DSearchRec); end; finally FindClose(FSearchRec); FindClose(DSearchRec); end;end;function TFormBackUp.CheckDisk(Drive: Byte; aSize: Int64): Boolean;var Bn, Chk: Integer; MySize: Int64;begin Result := True; Chk := 0; while Chk = 0 do begin MySize := DiskFree(Drive); if MySize = -1 then begin Bn := MessageDlg( 未插入磁盘或提供备份文件的位置不正确!如果未插入磁盘,请插入后单击“是”。 , mtWarning, mbYes, mbNo, 0); if bn = mrYes then Continue else begin Result := False; break; end; end else begin if MySize aSize then begin bn := MessageDlg( 驱动器剩余空间不足,如果使用磁盘,请插入另一张后单击“是”。 , mtWarning, mbYes, mbNo, 0); if bn = mrYes then Continue else begin Result := False; break; end; end else break; end; end;end;function TFormBackUp.CheckFileExists(aFileNameString: string): Boolean;var aFileExistText: string;begin Result := True; while FileExists(aFileNameString) do begin aFileExistText := 文件 + aFileNameString + 已存在,如果单击“确定”,将会以覆盖原文件的形式备份,继续吗? ; if (MessageDlg(aFileExistText, mtConfirmation, mbOKCancel, 0) idCancel) then begin Result := True; break; end else begin Result := False; break; end; end;end;procedure TFormBackUp.SpRestoreClick(Sender: TObject);begin if not FileExists(edFileName.Text) then begin MessageDlg(Format( 文件 %s 不存在! , edFileName.Text), mtError, mbOk, 0); Exit; end; with Archiver1 do begin FileName := edFileName.Text; ExtractPath := GetPath; Open; try ExtractFiles; finally Close; end; end;end;procedure TFormBackUp.SpSelectFileClick(Sender: TObject);begin with OpenDialog1 do begin if Execute then edFileName.Text := FileName; end;end;procedure TFormBackUp.SpBackUpClick(Sender: TObject);var tmp: string; mmmPath: string; DriveNumber: Integer; vByte: Char; DirectorySize: LongInt; aAliasText: string;begin try tmp := GetPath; mmmPath := UpperCase(trim(edFileName.Text); vByte := mmmPath1; DirectorySize := CheckFileSize(tmp); DriveNumber := Ord(vByte) - Ord( A ) + 1; if CheckDisk(DriveNumber, DirectorySize) = False then Exit; if CheckFileExists(mmmPath) then begin with Archiver1 do begin FileName := edFileName.Text; Open; try AddDirectory(tmp); finally Close; end; end; if RbAlias.Checked then begin aAliasText := a1 + CbAlias.Text + a2 + CbAlias.Text + a3; if (MessageDlg(aAliasText, mtConfirmation, mbYes, mbNo, 0) MrNo) then begin Bggl_Form.N1Click(nil); Form_DM.ADOD_Hzxx.Delete; end; end; end; except if IsClickStop then begin IsClickStop := False; raise Exception.Create( 进程被取消。 ); end else raise Exception.Create( 文件路径不合法,请仔细检查! ); end;end;procedure TFormBackUp.btnAbortClick(Sender: TObject);begin Archiver1.RequestAbort; IsClickStop := True;end;procedure TFormBackUp.Archiver1DisplayMessage(Sender: TObject; const msg: string);begin LFile.Caption := msg;end;procedure TFormBackUp.Archiver1FileProgress(Sender: TObject; Percent: Integer);begin ProgressBar1.Position := Percent; btnAbort.Enabled := Archiver1.CanAbort; Application.ProcessMessages;end;procedure TFormBackUp.Archiver1FinishOperation(Sender: TObject);begin NoteBook1.PageIndex := 0; Application.ProcessMessages;end;procedure TFormBackUp.Archiver1StartOperation(Sender: TObject);begin with Sender as TArchiver do begin if Operation = opAdd then begin lTitle.Caption := 正在备份. ; AnimateBackUp.Visible := True; AnimateRestore.Visible := False; end else if Operation = opExtract then begin lTitle.Caption := 正在恢复. ; AnimateBackUp.Visible := False; AnimateRestore.Visible := True; end else begin lTitle.Caption := ; AnimateBackUp.Visible := False; AnimateRestore.Visible := False; end; end; NoteBook1.PageIndex := 1;end;procedure TFormBackUp.FormCloseQuery(Sender: TObject; var CanClose: Boolean);begin CanClose := not Archiver1.IsBusy; if not CanClose then MessageDlg( 操作正在进行中.按“取消”按钮会退出操作。 , mtWarning, mbOk, 0);end;procedure TFormBackUp.FormCreate(Sender: TObject);var ApplicationPath: string;begin ApplicationPath := ExtractFilePath(Application.ExeName); RbAlias.Checked := True; with Form_DM.ADODataSet1 do begin try Close; OPen; CbAlias.Items.Clear; First; while not Eof do begin CbAlias.Items.Add(Fields0.AsString); Next; end; finally Close; end; end; AnimateBackUp.FileName := ReturnFileName(aviBackUp); AnimateRestore.FileName := ReturnFileName(aviRestore); AnimateBackUp.Active := True; AnimateRestore.Active := True; AnimateRestore.Visible := False; Notebook1.PageIndex := 0;end;procedure TFormBackUp.FormShow(Sender: TObject);var iCount: Integer;begin with CbAlias do begin for iCount := 0
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 通风排烟安装工程合同
- 2022学年上海交大附中高一(下)期中政治试题及答案
- 宇宙之谜探索诗歌中的艺术特色与灵感教学教案
- 春季活动策划方案
- 无锡2025高三期末语文作文(9篇)
- 词句积累与运用:古诗词赏析与记忆训练初中英语课教案
- 宇宙探索与科幻文学:初中语文拓展教学教案
- 公交公司联欢会活动方案
- 物质的三种状态及其性质:九年级科学物理教案
- 公众号售卖活动方案
- 北京市顺义区2023-2024学年五年级下学期数学期末试卷(含答案)
- 2025公基题库(附答案解析)
- 2025年宁夏银川灵武市选聘市属国有企业管理人员招聘笔试冲刺题(带答案解析)
- 机关内部制度管理制度
- 2025年高纯硫酸锶项目市场调查研究报告
- 2025年汽车驾照考试科目一考试题库及参考答案
- 广东省广州市天河区2023-2024学年七年级下学期期末考试英语试题(含答案)
- 净水机服务合同协议书
- 古城煤矿压风系统远程监控改造技术协议
- 2025年上海市公务员录用考试《行测》真题及答案解析(B类)
- 村务管理岗面试题及答案
评论
0/150
提交评论