Thread View: borland.public.cppbuilder.internet.web
2 messages
2 total messages
Started by ANTHONY WEST
Wed, 16 Jul 2008 08:01
Connect to a password protected file and download it
Author: ANTHONY WEST
Date: Wed, 16 Jul 2008 08:01
Date: Wed, 16 Jul 2008 08:01
21 lines
1733 bytes
1733 bytes
I am using Borland builder 4 standard. I have searched the internet for a couple of hours looking for tutorials/source code that will download a file from a password protected directory on my website. The main purpose is to have my app check for updates and download them if available. I don't care if the method goes through FTP or HTTP. I have a text file on my web server that contains the latest version information. I would prefer not to use any components because I am looking to understand how the code works. I found information for the MFC that shows how to do it, but those header files naturally will compile with Borland because they do not exists. Any pointers on how this could be done? -- Anthony West <-- What a great day to be alive :) -->
Re: Connect to a password protected file and download it
Author: Colin B Maharaj
Date: Tue, 22 Jul 2008 11:57
Date: Tue, 22 Jul 2008 11:57
82 lines
3554 bytes
3554 bytes
Hi Anthony, have you looked at wput?
It is a unix utility that connects to
a ftp server,logs in, and downloads a file.
This can be configured to run at the command
line. There is a windows port as well.
Another one is wget (opposite of wput)
I use it in my application as part of a scheduled
script.
Why tell you this?
Well why write something if it already exists.
and I have not used much FTP yet with Indy.
http://wput.sourceforge.net/
Another thing you can try is the WinINet routines,
remember these relay on Internet explorer....
example....
//--------------------------------------------------------------------------.
void SaveURLToFile(AnsiString UrlName, AnsiString FN)
{
HINTERNET hSession;
hSession = InternetOpen("AGENT", INTERNET_OPEN_TYPE_DIRECT, NULL,
NULL, 0);
if (hSession)
{
HINTERNET hService;
hService = InternetOpenUrl(hSession, UrlName.c_str(), NULL, 0, 0, 0);
if (hService)
{
DWORD dwBytesAvailable, dwBytesRead=1;
InternetQueryDataAvailable(hService, &dwBytesAvailable, 0, 0);
char *lpBuffer = new char [dwBytesAvailable+1];
int h = FileCreate(FN);
while (dwBytesRead != 0)
{
InternetReadFile(hService, lpBuffer, dwBytesAvailable,
&dwBytesRead);
FileWrite(h, lpBuffer, dwBytesRead);
}
delete lpBuffer;
FileClose(h);
}
}
InternetCloseHandle(hSession);
}
//--------------------------------------------------------------------------.
ANTHONY WEST wrote:
> I am using Borland builder 4 standard. I have searched
> the internet for a couple of hours looking for tutorials/source
> code that will download a file from a password protected
> directory on my website. The main purpose is to have my
> app check for updates and download them if available. I
> don't care if the method goes through FTP or HTTP.
>
> I have a text file on my web server that contains the
> latest version information.
>
> I would prefer not to use any components because I am
> looking to understand how the code works. I found information
> for the MFC that shows how to do it, but those header files
> naturally will compile with Borland because they do not
> exists.
>
> Any pointers on how this could be done?
>
> --
> Anthony West
> <-- What a great day to be alive :) -->
>
>
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads