H
hlei
Unregistered / Unconfirmed
GUEST, unregistred user!
function CompareFileSize(FileName1: String; FileName2: String): Integer;<br>var<br> SearchRec: TSearchRec;<br> File1Size: Longint;<br> File2Size: Longint;<br>begin<br> try<br> if FindFirst (ExpandFileName(FileName1),faAnyFile,SearchRec)=0<br> then<br> File1Size:= SearchRec.Size<br> else Result:= -1 //FileName1不存在,就返回 -1<br> finally<br> FindClose(SearchRec);<br> end;<br> try<br> if FindFirst (ExpandFileName(FileName2),faAnyFile,SearchRec)=0<br> then<br> File2Size:= SearchRec.Size<br> else Result:= -2 //FileName2不存在,就返回 -2<br> finally<br> FindClose(SearchRec);<br> end;<br><br> if File1size > File2Size then<br> Result:= 1 else //FileName1 > FileName2 返回 1<br> if File1Size < File2Size then<br> Result:= 2 else //FileName1 < FileName2 返回 2<br> Result:= 0 //FileName1 = FileName2 返回 0<br>end;<br><br>为什么 1 2 0 都可以正确返回,可是 -1 -2(就是文件不存在时)返回的还是1 2<br>请帮我看看。