Board index » delphi » when use HttpOpenRequest (),how to know the file is not exist?

when use HttpOpenRequest (),how to know the file is not exist?

Hi,every:

I use wininet funciton to download a file;
but when the file is not exist,
it give me a html file that tell not find the file.

Now i must know the file is not exsit before
call InternetReadFile().

How to do it?

chenhongqi

 

Re:when use HttpOpenRequest (),how to know the file is not exist?


I settle it:

FTResult := HttpQueryInfo(hRequest, HTTP_QUERY_STATUS_CODE,
                              Buf, dwBufLen, dwIndex);
if StrToInt(StrPas(Buf))=HTTP_STATUS_NOT_FOUND then
begin
   Error('Error?oHttpQueryInfo,No find file (404)',4404);
end;

chenhongqi

Quote
"3?o?" <c...@email.jrj.com.cn> wrote in message news:3cbfe0d4_2@dnews...
> Hi,every:

> I use wininet funciton to download a file;
> but when the file is not exist,
> it give me a html file that tell not find the file.

> Now i must know the file is not exsit before
> call InternetReadFile().

> How to do it?

> chenhongqi

Re:when use HttpOpenRequest (),how to know the file is not exist?


sorry,it donot work!!!

FTResult := HttpQueryInfo(hRequest, HTTP_QUERY_STATUS_CODE,
                              Buf, dwBufLen, dwIndex);

if StrToInt(StrPas(Buf))=HTTP_STATUS_NOT_FOUND then
    begin
      Error('Error?oHttpQueryInfo,No find file (404)',4404);
    end;

FTResult := HttpQueryInfo(hRequest, HTTP_QUERY_CONTENT_LENGTH,
                              Buf, dwBufLen, dwIndex);

anyway,the second call return false;
why????

chenhongqi

Quote
"3?o?" <c...@email.jrj.com.cn> wrote in message news:3cbfe0d4_2@dnews...
> Hi,every:

> I use wininet funciton to download a file;
> but when the file is not exist,
> it give me a html file that tell not find the file.

> Now i must know the file is not exsit before
> call InternetReadFile().

> How to do it?

> chenhongqi

Other Threads