How do i read a txt file from a webserver

hi everyone,
i would like to save some data in the website in a txt file and i would like to read the file using delphi and display it in the client window

for eg: if the
Host Name :
User Name : xxxxxx
Password  : xxxxxx
And the file name is myfirst.txt

i want to open the file and read the data in it plz help me........... Sam
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

There are a set of internet components available through

One is an FTP client that will log in and download the file for you, or if you can access it from the web like, you can do that with the http component and would be faster as it wouldn't need to log in etc.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Here is a function that you call with the full url of your text file e.g:

PageText := GetHTMLPage(;

You should include WinInet in your uses clause for the function to work.
function GetHTMLPage(strURL: String): String;
const BufferSize = 1024;
     hSession, hURL: HInternet;
     Buffer: array[1..BufferSize] of Byte;
     BufferLen: DWORD;
     mStrm: TMemoryStream;
     Result := '';
     hSession := InternetOpen(PChar('MyApplication'), INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0);
     if hSession<>nil then try
          hURL := InternetOpenURL(hSession, PChar(strURL), nil, 0, 0, 0);
          if hURL<>nil then try
               mStrm := TMemoryStream.Create;
                         InternetReadFile(hURL, @Buffer, SizeOf(Buffer), BufferLen);
                         if BufferLen>0 then mStrm.WriteBuffer(Buffer, BufferLen);
                    until BufferLen = 0;
                    SetLength(Result, mStrm.Size);
                    CopyMemory(@Result[1], mStrm.memory, mStrm.Size);

This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Post your closing recommendations!  No comment means you don't care.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.