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 : ftp.tripod.com
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
samuel_prasannaAsked:
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.

PaivlekCommented:
There are a set of internet components available through www.overbyte.be

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 www.tripod.com/user/myfirst.txt, you can do that with the http component and would be faster as it wouldn't need to log in etc.
0

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
emadatCommented:
Here is a function that you call with the full url of your text file e.g:

PageText := GetHTMLPage(http://www.your_site.com/textfile.txt);

You should include WinInet in your uses clause for the function to work.
//=======================================================
function GetHTMLPage(strURL: String): String;
const BufferSize = 1024;
var
     hSession, hURL: HInternet;
     Buffer: array[1..BufferSize] of Byte;
     BufferLen: DWORD;
     mStrm: TMemoryStream;
begin
     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;
               try
                    repeat
                         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);
               finally
                    mStrm.Free;
               end;
          finally
               InternetCloseHandle(hURL);
          end
     finally
          InternetCloseHandle(hSession);
     end;
end;
//=======================================================

Emad
0
CleanupPingCommented:
samuel_prasanna:
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 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
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
Delphi

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.