?
Solved

HTTP/FTP file details?

Posted on 1998-01-25
5
Medium Priority
?
420 Views
Last Modified: 2013-12-03
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
0
Comment
Question by:matth012098
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 3

Author Comment

by:matth012098
ID: 1410331
BTW I am using Microsofts Visual C++ v5.0

0
 
LVL 32

Expert Comment

by:jhance
ID: 1410332
CInternetFile is derived from CStdioFile which is derived from CFile.  CFile has a class member CFile::GetStatus() which will gove you the information.  
0
 
LVL 3

Author Comment

by:matth012098
ID: 1410333
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_BINARY, "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

0
 
LVL 3

Author Comment

by:matth012098
ID: 1410334
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::GetFtpConnection(). 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

0
 
LVL 7

Accepted Solution

by:
linda101698 earned 200 total points
ID: 1410335
I'm posting matth's solution so it can be moved to the previously asked questions.

Customer Service at Experts Exchange

Solution:
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::GetFtpConnection(). 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?
0

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question