matth012098
asked on
HTTP/FTP file details?
I am using the MFC class CInternetFile and have stumbled across a small problem. How do I get various details of a file situated on the internet using HTTP/FTP protocols. I need to know the last modified date of the file and the name of the file.
Mat
Mat
CInternetFile is derived from CStdioFile which is derived from CFile. CFile has a class member CFile::GetStatus() which will gove you the information.
ASKER
It didnt work. It returns the date last modified for all file types I downloaded as 1st January 1970 and the file size was 0 bytes. I am using the following code to get the last time the file wqas modified and size, can you spot any probs?
file = (CInternetFile *)session.OpenURL(URL, 1, INTERNET_FLAG_TRANSFER_BIN ARY, "Accept: */*\r\n\r\n", -1);
CFileStatus status;
CTime *time;
CString s;
LONG file_size;
file->GetStatus(status);
time = &status.m_mtime;
s = time->Format("%A, %B, %d, %Y");
file_size = status.m_size;
No matter which protocol I use I get the same, I can get the http file size and other stats using another routine someone gave me, but what about FTP?
matth
file = (CInternetFile *)session.OpenURL(URL, 1, INTERNET_FLAG_TRANSFER_BIN
CFileStatus status;
CTime *time;
CString s;
LONG file_size;
file->GetStatus(status);
time = &status.m_mtime;
s = time->Format("%A, %B, %d, %Y");
file_size = status.m_size;
No matter which protocol I use I get the same, I can get the http file size and other stats using another routine someone gave me, but what about FTP?
matth
ASKER
I have solved the problem myself. In order to get the size of an ftp internet file, you must firstly get a CFtpConnection from CInternetSession::GetFtpCo nnection() . This will log you onto the ftp server. You then need to change into the correct directory that contains the file you need to know the details of on the ftp server and use CFtpFileFind::FindFile() to find the file. You then need to call CFtpFileFind::FindNextFile () for some reason which I still dont know. You then call CFtpFileFind::GetLength() to get the length and so on.
What a lot of messing about, I thought MFC was supposed to make things easier?
matth
What a lot of messing about, I thought MFC was supposed to make things easier?
matth
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER