Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

GetFileInformationByHandle

Posted on 2006-06-13
3
Medium Priority
?
516 Views
Last Modified: 2013-11-20
I am downloading a file from a remote ftp site.  I want to check the ftp filename creation date time to make sure I dont donwload thesame file twice.

GetFileInformationByHandle is not returning the correct file creation date & time of an FTP file.

What's wrong with this code???

I have this code:

      BOOL bDestFileOpen=FALSE;
      CInternetFile*  ifp=NULL;
      try
      {
            ifp = m_Ftp_Conn->OpenFile(source);
            if(ifp)
            {
                  DWORD dwSizeHigh;
                  DWORD dwSizeLow;
                  BY_HANDLE_FILE_INFORMATION info;
                  ::GetFileInformationByHandle( ifp->m_hFile, &info );
                  dwSizeHigh = info.nFileSizeHigh;
                  dwSizeLow = info.nFileSizeLow;            //this will handle up to 4GIG

...
                  CTime fileTime(info.ftCreationTime.dwLowDateTime);
                  CString temp;
                  temp.Format(L"File Date = %02d/%02d/%04d Time = %02d:%02d:%04d",
                        fileTime.GetMonth(),fileTime.GetDay(),fileTime.GetYear(),
                        fileTime.GetHour(),fileTime.GetMinute(),fileTime.GetSecond());
            
0
Comment
Question by:ramrocket
[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
  • 2
3 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 16897771
As the docs state: "Depending on the underlying network components of the operating system and the type of server connected to, the GetFileInformationByHandle function may fail, return partial information, or full information for the given file."

I'd rather suggest to

LPWIN32_FIND_DATA wfd;

HINTERNET hFind = FtpFindFirstFile(fp->m_hFile,source,wfd,INTERNET_FLAG_DONT_CACHE,0);

InternetCloseHandle(hFind);

               CTime fileTime(wfd.ftCreationTime.dwLowDateTime);
               CString temp;
               temp.Format(L"File Date = %02d/%02d/%04d Time = %02d:%02d:%04d",
                    fileTime.GetMonth(),fileTime.GetDay(),fileTime.GetYear(),
                    fileTime.GetHour(),fileTime.GetMinute(),fileTime.GetSecond());
         
0
 

Author Comment

by:ramrocket
ID: 16897921
jkr, it would crash on the call to CTime fileTime(wfd->ftCreationTime.dwLowDateTime);
0
 
LVL 86

Accepted Solution

by:
jkr earned 800 total points
ID: 16899168
>>it would crash on the call to CTime fileTime(wfd->ftCreationTime.dwLowDateTime);

Sorry, typo, that should be

WIN32_FIND_DATA wfd;

HINTERNET hFind = FtpFindFirstFile(fp->m_hFile,source,wfd,INTERNET_FLAG_DONT_CACHE,0);

InternetCloseHandle(hFind);

               CTime fileTime(wfd.ftCreationTime.dwLowDateTime);
               CString temp;
               temp.Format(L"File Date = %02d/%02d/%04d Time = %02d:%02d:%04d",
                    fileTime.GetMonth(),fileTime.GetDay(),fileTime.GetYear(),
                    fileTime.GetHour(),fileTime.GetMinute(),fileTime.GetSecond());
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

722 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