![]() |
![]() ![]() ![]() |
WinHTTP component.
|
type
|
TWinHTTPFileAttribute = (atrArchive, atrHidden, atrReadOnly, atrSystem, atrTemporary, atrOffline);
|
TWinHTTPFileAttributes = set of TWinHTTPFileAttribute;
|
|
TWinHTTPOutputFileAttributes = class
|
published
|
property Complete: TWinHTTPFileAttributes default [atrArchive];
|
property Incomplete: TWinHTTPFileAttributes default [atrArchive, atrTemporary];
|
end;
|
|
property OutputFileAttributes: TWinHTTPOutputFileAttributes;
|
The OutputFileAttributes property allows to specify the file attributes for file which being downloaded to location specified in OutputFileName property.
|
|
There is 2 "sub-properties": Complete and Incomplete.
|
|
Incomplete property specifies flags for incomplete file which still being downloaded (or paused, but still not downloaded to local drive completely).
|
|
Complete specifies attributes which being set to the OutputFileName once the download finished and file completely downloaded.
|
|
![]() |
|
Also, anyway you will be able to rename the downloaded file and change its file attributes (using SetFileAttributes WinAPI), in the OnDone event handler.
|
![]() |
WinHTTP1.URL := 'http://www.domain.com/filename.zip';
|
WinHTTP1.OutputFileName := 'c:\filename.zip';
|
WinHTTP1.OutputFileAttributes.Complete := [atrArchive]; // Normal
|
WinHTTP1.OutputFileAttributes.Incomplete := [atrArchive, atrHidden]; // "hide" incomplete file
|
WinHTTP1.Read;
|
|
// and when file will be successfully downloaded you can
|
// change the file attributes to Normal in the OnDone event handler
|
procedure TForm1.WinHTTP1Done(Sender: TObject; const ContentType: string;
|
FileSize: Integer; Stream: TStream);
|
begin
|
// set file attributes to normal
|
Windows.SetFileAttributes(PChar(FileSize), FILE_ATTRIBUTE_NORMAL);
|
end;
|
OutputFileName property;
|
Read, ReadRange, Resume and Pause methods;
|
OnOutputFileError and OnDone events.
|