TC中Add File & Compare File使用介绍

添加需要比较的文件有以下3种方法:
 
//1.Add files from the Files editor
//2.Add files from the Project Explorer
//3.Add files from scrīpts

在TC里,封装了好几个文件比较的方法,主要有以下几种:
//4.Comparing files by bytes
//使用正则表达式比较文件(RegExpr)
//5.Comparing files with variable parts

具体使用如下:

procedure AddfileFromscrīpt;
begin
  if not Files.Add('../../TestFile_old.txt', 'TestFile_old') then
    Log.Message(Files.LastError);
  if not Files.Add('../../TestFile_new.txt', 'TestFile_new') then
    Log.Message(Files.LastError);
  if not Files.Add('../../TestFile_new_space.txt', 'TestFile_new_space') then
    Log.Message(Files.LastError);
end;

//获取文件方式
//FileNameByIndex、FileNameByName、NameByIndex 、NameByFileName 、FileNamesList、NamesList
procedure GetFile;
begin
  showmessage(Files.FileNameByIndex(0));
end;

//常用比较文件方式
procedure ComparefileBytes;
begin
  if not Files.Compare(files.FileNameByName('TestFile_old'), files.FileNameByName('TestFile_new')) then
    showmessage(files.LastError);
end;

//通过Hash值比较文件
procedure ComparefileHash;
var Hash : OleVariant;//Hash记录两个文件的差异值
begin
  Hash := Files.CalculateHashValue(files.FileNameByName('TestFile_old'), files.FileNameByName('TestFile_new_space'));
  if not Files.Compare(files.FileNameByName('TestFile_old'), files.FileNameByName('TestFile_new_space'),Hash) then
    showmessage(files.LastError)
  else showmessage('The two files is equal!');
end;

procedure Test_Sample;
begin
  Aliases.TCSampleForm.Drag(224, 17, 162, 0);
  Aliases.TCSampleSys.Process('Explorer').Window('Shell_TrayWnd').Window('ReBarWindow32').Window('MSTaskSwWClass', '运行应用程序').Window('ToolbarWindow32', '运行应用程序').CheckItem('TestComplete - C:/Documents and Settings/temp/桌面/hzr-TechED/TCSamples/TCSamples', -1, false);
end;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值