Learn the datasanp of Yong Nan blog download files while recording Windows system logs

Source: Internet
Author: User

Server-side:

function Tservermethods1.getfile (filename:string): TStream;
Var
filepath,downfile:string;
Fs:tfilestream;
Log:teventlogger;//need to add vcl.svcmgr in uses to refer to Teventlogger
Begin
filepath:= ' d:\xe\ ';
Downfile:=filepath+filename;
Log:=teventlogger.create (' mymessage ');//Create a message
Log. LogMessage (downfile);//Output a message
Result:=nil;
If not fileexists (downfile) THEN BEGIN
Log. LogMessage (' file does not exist '),//In the output of one, will produce two logs
Exit;
End
Result:=tfilestream.create (Downfile,fmopenread);
If Result<>nil Then
result.position:=0;
End

Client:

Procedure Tform4.btn1click (Sender:tobject);
Const
buffersize=10240;
Var
Con:tservermethods1client;
Fstream:tstream;
Filefs:tfilestream;
Buffer:tbytes;
Count:integer;
Begin
Con:=tservermethods1client.create (sqlconnection1.dbxconnection);
count:=0;
SetLength (Buffer, buffersize);

After downloading from the server, rename Delphidown.pdf '
Filefs:=tfilestream.create (' d:\delphidown.pdf ', fmcreate);

Try
Fstream:=con.getfile (' delphi.pdf ');//file name on the server, the server must have
Edt1. Text:=con. ReverseString (' abc ');//This is used to drop a string flip with its own example
Repeat
Count:=fstream.read (buffer[0],buffersize);//Read the stream continuously
If Count>0 Then

Read the stream, write to ' d:\delphidown.pdf '
Filefs.writebuffer (Buffer[0],count);

Until (count<buffersize);
Except

End
End

Note the place:

1. Windows to enable the logging service. Otherwise you'll see the output log.

2. Viewing days

In Computer Management, you can view the system log:

Learn the datasanp of Yong Nan blog download files while recording Windows system logs

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.