Hello,
I am a beginner/intermediate c++ coder. I have a program that I am
writing and would like to be able to distribute to some of my
friends. The problem with this is that the data files required by it
are rather large, and most of them have email accounts with filesize
limits. What I want to do is upload the files they'll need to my
webpage and then have the program itself check to see if the files are
present in the directories (I know how to do this part) and if they
aren't found, then connect to my homepage and download the files.
So basically, the code flow will go like this:
User runs program
Check for File A
File A Not Found
Prompt User -Not Found, Would you like to Download?
if User says Yes
//THIS IS THE PART I NEED TO BE ABLE TO DO
DownloadFile(File A) from MyHomepage
//END PART I NEED TO KNOW
if user says no
exit program
I found some confusing crap about MFC and etc, but I really need
something in straight c/c++ that can do this same thing, if possible.
If win32 API is a must, or easier, then that would work too I suppose,
but I'm trying to find the most flexible solution I can. Thanks in
advance!
-Steve 7 2430
* Steve:
Hello,
I am a beginner/intermediate c++ coder. I have a program that I am
writing and would like to be able to distribute to some of my
friends. The problem with this is that the data files required by it
are rather large, and most of them have email accounts with filesize
limits. What I want to do is upload the files they'll need to my
webpage and then have the program itself check to see if the files are
present in the directories (I know how to do this part) and if they
aren't found, then connect to my homepage and download the files.
So basically, the code flow will go like this:
User runs program
Check for File A
File A Not Found
Prompt User -Not Found, Would you like to Download?
if User says Yes
//THIS IS THE PART I NEED TO BE ABLE TO DO
DownloadFile(File A) from MyHomepage
//END PART I NEED TO KNOW
if user says no
exit program
I found some confusing crap about MFC and etc, but I really need
something in straight c/c++ that can do this same thing, if possible.
If win32 API is a must, or easier, then that would work too I suppose,
but I'm trying to find the most flexible solution I can. Thanks in
advance!
The C++ standard library doesn't support this directly. You could run a
second program to do the downloading, or use a library. Many such
libraries are available.
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Hi
Here is some ezample code include the wininet.h header. This is microsoft
specific is not going to work on any unix. All the Internet and Ftp
functions are microsoft specific. On unix either write your own transfer
protocol using sockets (it really isn't that difficult) or if you want to
use ftp either use system in combination with a .netrc file and a macro
(don't forget to set the permissions chmod 600 on the .netrc file or it will
not work) or link to a ftp library (though I don't know of any free one).
Cheers,
if( InternetAttemptConnect( 0 ) == ERROR_SUCCESS )
{
HINTERNET Session;
if( !( Session = InternetOpen( _T( "Pollux" ), INTERNET_OPEN_TYPE_DIRECT,
0, 0, 0 ) ) )
{
AfxMessageBox( _T( "Could setup internet session" ) );
Succeeded = false;
}
else
{
HINTERNET Connection;
if( !( Connection = InternetConnect( Session, m_Server,
INTERNET_DEFAULT_FTP_PORT, m_User,
m_Password, INTERNET_SERVICE_FTP, 0, 0 ) ) )
{
AfxMessageBox( _T( "Could not establish ftp session" ) );
Succeeded = false;
}
else
{
if( !FtpCreateDirectory( Connection, _T( "Cons" ) ) )
{
//AfxMessageBox( "Could not Create 'Cons' dir on server!" );
// Likely it already existed since we try this every time :-)
}
if( !FtpCreateDirectory( Connection, _T( "Prog" ) ) )
{
//AfxMessageBox( "Could not Create 'Cons' dir on server!" );
// Likely it already existed since we try this every time :-)
}
for( int Cnt = 0; Cnt < sizeof( Files ) /
sizeof( TCHAR* ); Cnt++ )
{
FtpPutFile( Connection, Files[ Cnt ], Files[ Cnt ],
INTERNET_FLAG_TRANSFER_BINARY, NULL );
}
InternetCloseHandle( Connection );
}
InternetCloseHandle( Session );
}
}
else
{
AfxMessageBox( CString( "Could not connect to " ) + m_Server );
Succeeded = false;
}
if( Succeeded )AfxMessageBox( "De webpages staan nu op de
server",MB_ICONINFORMATION|MB_OK );
}
Regards, Ron AF Greve http://www.InformationSuperHighway.eu
"Steve" <st******************@gmail.comwrote in message
news:11*********************@j27g2000cwj.googlegro ups.com...
Hello,
I am a beginner/intermediate c++ coder. I have a program that I am
writing and would like to be able to distribute to some of my
friends. The problem with this is that the data files required by it
are rather large, and most of them have email accounts with filesize
limits. What I want to do is upload the files they'll need to my
webpage and then have the program itself check to see if the files are
present in the directories (I know how to do this part) and if they
aren't found, then connect to my homepage and download the files.
So basically, the code flow will go like this:
User runs program
Check for File A
File A Not Found
Prompt User -Not Found, Would you like to Download?
if User says Yes
//THIS IS THE PART I NEED TO BE ABLE TO DO
DownloadFile(File A) from MyHomepage
//END PART I NEED TO KNOW
if user says no
exit program
I found some confusing crap about MFC and etc, but I really need
something in straight c/c++ that can do this same thing, if possible.
If win32 API is a must, or easier, then that would work too I suppose,
but I'm trying to find the most flexible solution I can. Thanks in
advance!
-Steve
I was looking over this, and it kindof looks like this code will
upload a file from the local computer to a server, but I'm trying to
download something from a server to my local computer. Or am I
reading it wrong? Thanks!
-Steve
On Feb 22, 7:23 pm, "Ron AF Greve" <news moonlit xs4all nlwrote:
Hi
Here is some ezample code include the wininet.h header. This is microsoft
specific is not going to work on any unix. All the Internet and Ftp
functions are microsoft specific. On unix either write your own transfer
protocol using sockets (it really isn't that difficult) or if you want to
use ftp either use system in combination with a .netrc file and a macro
(don't forget to set the permissions chmod 600 on the .netrc file or it will
not work) or link to a ftp library (though I don't know of any free one).
Cheers,
if( InternetAttemptConnect( 0 ) == ERROR_SUCCESS )
{
HINTERNET Session;
if( !( Session = InternetOpen( _T( "Pollux" ), INTERNET_OPEN_TYPE_DIRECT,
0, 0, 0 ) ) )
{
AfxMessageBox( _T( "Could setup internet session" ) );
Succeeded = false;
}
else
{
HINTERNET Connection;
if( !( Connection = InternetConnect( Session, m_Server,
INTERNET_DEFAULT_FTP_PORT, m_User,
m_Password, INTERNET_SERVICE_FTP, 0, 0 ) ) )
{
AfxMessageBox( _T( "Could not establish ftp session" ) );
Succeeded = false;
}
else
{
if( !FtpCreateDirectory( Connection, _T( "Cons" ) ) )
{
//AfxMessageBox( "Could not Create 'Cons' dir on server!" );
// Likely it already existed since we try this every time :-)
}
if( !FtpCreateDirectory( Connection, _T( "Prog" ) ) )
{
//AfxMessageBox( "Could not Create 'Cons' dir on server!" );
// Likely it already existed since we try this every time :-)
}
for( int Cnt = 0; Cnt < sizeof( Files ) /
sizeof( TCHAR* ); Cnt++ )
{
FtpPutFile( Connection, Files[ Cnt ], Files[ Cnt ],
INTERNET_FLAG_TRANSFER_BINARY, NULL );
}
InternetCloseHandle( Connection );
}
InternetCloseHandle( Session );
}
}
else
{
AfxMessageBox( CString( "Could not connect to " ) + m_Server );
Succeeded = false;
}
if( Succeeded )AfxMessageBox( "De webpages staan nu op de
server",MB_ICONINFORMATION|MB_OK );
}
Regards, Ron AF Greve
http://www.InformationSuperHighway.eu
Hi Steve,
No, you are perfectly right :-)
It was just a cut and paste of some code of mine.
My guess is that you just replace the put with a get. However do look up on
either msdn or in the microsoft help information. I think you also have to
add some libraries to the linker (somewhere in the properties linker input
tab from the top of my head). Libraries I think wininet, ws_32 or something
but all of that is on the helppages.
Regards, Ron AF Greve http://www.InformationSuperHighway.eu
"Steve" <st******************@gmail.comwrote in message
news:11*********************@k78g2000cwa.googlegro ups.com...
>I was looking over this, and it kindof looks like this code will
upload a file from the local computer to a server, but I'm trying to
download something from a server to my local computer. Or am I
reading it wrong? Thanks!
-Steve
On Feb 22, 7:23 pm, "Ron AF Greve" <news moonlit xs4all nlwrote:
>Hi
Here is some ezample code include the wininet.h header. This is microsoft specific is not going to work on any unix. All the Internet and Ftp functions are microsoft specific. On unix either write your own transfer protocol using sockets (it really isn't that difficult) or if you want to use ftp either use system in combination with a .netrc file and a macro (don't forget to set the permissions chmod 600 on the .netrc file or it will not work) or link to a ftp library (though I don't know of any free one).
Cheers,
if( InternetAttemptConnect( 0 ) == ERROR_SUCCESS ) { HINTERNET Session;
if( !( Session = InternetOpen( _T( "Pollux" ), INTERNET_OPEN_TYPE_DIRECT, 0, 0, 0 ) ) ) { AfxMessageBox( _T( "Could setup internet session" ) ); Succeeded = false; } else { HINTERNET Connection; if( !( Connection = InternetConnect( Session, m_Server, INTERNET_DEFAULT_FTP_PORT, m_User, m_Password, INTERNET_SERVICE_FTP, 0, 0 ) ) ) { AfxMessageBox( _T( "Could not establish ftp session" ) ); Succeeded = false; } else { if( !FtpCreateDirectory( Connection, _T( "Cons" ) ) ) { //AfxMessageBox( "Could not Create 'Cons' dir on server!" ); // Likely it already existed since we try this every time :-) }
if( !FtpCreateDirectory( Connection, _T( "Prog" ) ) ) { //AfxMessageBox( "Could not Create 'Cons' dir on server!" ); // Likely it already existed since we try this every time :-) }
for( int Cnt = 0; Cnt < sizeof( Files ) / sizeof( TCHAR* ); Cnt++ ) { FtpPutFile( Connection, Files[ Cnt ], Files[ Cnt ], INTERNET_FLAG_TRANSFER_BINARY, NULL ); }
InternetCloseHandle( Connection );
}
InternetCloseHandle( Session ); } } else { AfxMessageBox( CString( "Could not connect to " ) + m_Server ); Succeeded = false; }
if( Succeeded )AfxMessageBox( "De webpages staan nu op de server",MB_ICONINFORMATION|MB_OK );
}
Regards, Ron AF Greve
http://www.InformationSuperHighway.eu
I think the easiest thing is to create a socket to your webserver and
download the file and there are tons and tons of examples on the web
for it. just look up socket.h
Ron AF Greve wrote:
Hi
Here is some ezample code include the wininet.h header.
Completely off-topic. Also, please don't top-post. Your replies belong
following or interspersed with properly trimmed quotes. See the
majority of other posts in the newsgroup, or the group FAQ list:
<http://www.parashift.com/c++-faq-lite/how-to-post.html>
Steve wrote:
I was looking over this, and it kindof looks like this code will
upload a file from the local computer to a server, but I'm trying to
download something from a server to my local computer. Or am I
reading it wrong? Thanks!
You're off-topic. Go elsewhere. Please don't top-post. Your replies
belong following or interspersed with properly trimmed quotes. See the
majority of other posts in the newsgroup, or the group FAQ list:
<http://www.parashift.com/c++-faq-lite/how-to-post.html> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Yannick Bétemps |
last post by:
Hi all,
As says the topic, I recently encountered problems with customers using
one of my file management applications and being protected in the same
time with Norton Internet Security firewall....
|
by: John Lauwers |
last post by:
Hi,
Can I download a file automatically from internet, Just type the internet
adress in a textbox and in another textbox the pad where it will be saved
and then push a button so the downloaded...
|
by: Finbar |
last post by:
Hello, i'm trying to download a text file;
www.float.com.au/download/20040915.txt
The Internet Transfer Control maybe downloading the whole file but only the
first line of the file is being...
|
by: Stephan Ainley |
last post by:
Is there a way to have some sort of
File.Exist("http://www.google.com/img.gif) or whatever using the internet?
I'm downloading files using the System.Net.WebClient class and have just
been using...
|
by: Ofer Lavi |
last post by:
Hi,
I am trying to build an activeX that, if missing, will be downloaded
and setup automatically on the client's browser (internet explorer).
Using VB6, it was easy, using the <Object> tag,...
|
by: Martin Ho |
last post by:
My application (before is actually fully loads) should check if user
is connected to internet.
Is there any way to check this with certainty?
Thanks a lot.
Martin
----== Posted via...
|
by: mouac01 |
last post by:
I'm not sure if this is possible. I would like to have a PHP app on
the Internet connect and write to a local database (Intranet). For
example, users would go to a web site...
|
by: Kurt Jakobsen |
last post by:
Hello,
I want to parse some info from a page that I've found on internet on a daily basis. To look up this page on internet explorer, and save it on my disk manually is no option.
The file can...
|
by: fiona |
last post by:
Yucca Valley, CA, - October 2007: Catalyst Development Corporation,
publisher of SocketTools, SocketWrench and LogicGem, today announced
the release of Catalyst File Transfer .NET V5.0. For...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: erikbower65 |
last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps:
1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal.
2. Connect to...
|
by: linyimin |
last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
|
by: erikbower65 |
last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA:
1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
|
by: Taofi |
last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same
This are my field names
ID, Budgeted, Actual, Status and Differences
...
|
by: DJRhino1175 |
last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this -
If...
|
by: DJRhino |
last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer)
If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _
310030356 Or 310030359 Or 310030362 Or...
|
by: lllomh |
last post by:
How does React native implement an English player?
|
by: Mushico |
last post by:
How to calculate date of retirement from date of birth
| |