Re: How to convert ftp to http
HTTP is not really a very good replacement for FTP, you will loose alot of
functionality.
But here is something to get you started.
I think that all you will have to do is call OpenURL with the name of the
file that you want on the server. I also think you can use OpenURL to get
the content of the directory.
AliR.
"Daniel" <imransheikh100@hotmail.com> wrote in message
news:1148408074.629660.207200@g10g2000cwb.googlegroups.com...
Hey every one,
I have an application that copy some files with FTP to local folder
(tmp folder).
These files are used for list of articles in tree control and some
images.
I have not much experience with C++/MFC. This small application is
made with help of someone else and that person is no more available.
Can someone help to convert this ftp part which copies the files to
local folder into http so that instead of copying these files to local
folder, the application can read the files from the website?
I will be very great full
Thanks in advance.
// Create Internet session
m_pInetSession = new CInternetSession("Application_Name");
if (!m_pInetSession)
MessageBox("Internet session could not be created", "Error",
MB_OK|MB_ICONERROR);
// Create ftp connection and download data
// Create Session Object
try
{
m_pFtpConnection = m_pInetSession->GetFtpConnection("Server_Name",
"User_Name", "Password");
}
catch (CInternetException* pEx)
{
// catch errors from WinINet
TCHAR szErr[1024];
if (pEx->GetErrorMessage(szErr, 1024))
MessageBox(szErr, "Error", MB_OK|MB_ICONERROR);
else
MessageBox("Exception occurred connecting server", "Error",
MB_OK|MB_ICONERROR);
pEx->Delete();
m_pFtpConnection = NULL;
}
// Set current directory and download data
m_pFtpConnection->SetCurrentDirectory(strRemoteDir);
// Find the file
CFileFind localFinder;
if (!localFinder.FindFile(strLocalPath))
if (!m_pFtpConnection->GetFile(File_Name, File_LocalPath))
MessageBox("Error downloading data", "Error", MB_OK|MB_ICONERROR);
localFinder.Close();
// Set the new downloaded image
newObj.img = Image::FromFile(strLocalPath.AllocSysString());
wait.Restore ();
}