Thread: manipulate date on files

  1. #1
    Registered User
    Join Date
    Mar 2007
    Posts
    12

    manipulate date on files

    I have a problem how do i write back the c_file.time_write to the files ?

    Code:
     if( (hFile = _findfirst( "*.bmp", &c_file )) == -1L )
           printf( "No *. bmp files in current directory!\n" );
       else
       {
    
               c_file.time_write = rand(lDateTime);
       }
    
    while( _findnext( hFile, &c_file ) == 0 )
                {
                      c_file.time_write = rand(lDateTime);
                 }

    Basically i need to change the dates to random values if there is a way please tell me anyone

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Well we could spend some time guessing your OS and compiler...
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Mar 2007
    Posts
    12
    Sorry salem its Windows and my compiler is Dev C++

  4. #4
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by Salem View Post
    Well we could spend some time guessing your OS and compiler...
    findfirst() is a Windows function, with legacy dating back to the days of MS-DOS.

  5. #5
    Registered User
    Join Date
    Mar 2007
    Posts
    12
    Do u have any idea how can i set the dates to what ever i like ? i dont have to use thoes functions

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Which is in itself ironic, since they seem to be using a win32 compiler on a win32 OS.

    http://faq.cprogramming.com/cgi-bin/...&id=1044780608
    Read xtree.cpp at the end.
    Then look for related API calls on msdn.microsoft.com until you find the one for changing attributes.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  7. #7
    Registered User
    Join Date
    Mar 2007
    Posts
    12
    its not win32 but a console

  8. #8
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    It's still the win32 API though.
    Did you read the FAQ?
    Did you see #include <windows.h> in the xtree.cpp example?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Error opening files in a different dir
    By Ozzie in forum C++ Programming
    Replies: 3
    Last Post: 10-09-2008, 06:55 AM
  2. Linking header files, Source files and main program(Accel. C++)
    By Daniel Primed in forum C++ Programming
    Replies: 3
    Last Post: 01-17-2006, 11:46 AM
  3. Multiple Cpp Files
    By w4ck0z in forum C++ Programming
    Replies: 5
    Last Post: 11-14-2005, 02:41 PM
  4. Folding@Home Cboard team?
    By jverkoey in forum A Brief History of Cprogramming.com
    Replies: 398
    Last Post: 10-11-2005, 08:44 AM
  5. Batch file programming
    By year2038bug in forum Tech Board
    Replies: 10
    Last Post: 09-05-2005, 03:30 PM