PRB: _dos_setftime() Fails to Set Date & Time for Network File

Last reviewed: July 17, 1997
Article ID: Q68797
5.10 6.00 6.00a 6.00ax 7.00 | 5.10 6.00 6.00a | 1.00 1.50
MS-DOS                      | OS/2            | WINDOWS
kbprg kbprb

The information in this article applies to:

  • The C Run-time (CRT), included with:

        - Microsoft C for MS-DOS, versions 5.1, 6.0, 6.0a, and 6.0ax
        - Microsoft C for OS/2, versions 5.1, 6.0, and 6.0a
        - Microsoft C/C++ for MS-DOS, version 7.0
        - Microsoft Visual C++ for Windows, versions 1.0 and 1.5
    

SYMPTOMS

The _dos_setftime() function is used to set the date and time of a file. If the file is on a local drive, the function behaves as expected; however, if the file resides on a network drive, the date and time returned by subsequent _dos_getftime() will not return the new values.

The date and time of the file on the network will be set. However, _dos_getftime() will not recognize the change until the file has been closed and re-opened.

STATUS

The C run-time library is performing as expected. The problem is a limitation of either the operating system or the network software.

MORE INFORMATION

Sample Code

/* Compile options needed: none
*/

#include <stdio.h>
#include <dos.h>
#include <stdlib.h>
#include <fcntl.h>

void main(void)
{
    int fh;
    unsigned int new_date = 0x184f;     /*   2/15/92   */
    unsigned int new_time = 0x48e0;     /*   9:07 AM   */
    unsigned int old_time, old_date;

   if( _dos_open("test.dat", O_RDONLY, &fh) != 0)
      exit(1);

   _dos_getftime( fh, &old_date, &old_time );
   system("dir test.dat");

   _dos_setftime( fh, new_date, new_time );
   system("dir test.dat");

   _dos_close( fh );
   if( _dos_open("test.dat", O_RDONLY, &fh) != 0)
      exit(1);

   printf("\nAfter closing and reopening the file.\n");
   _dos_getftime( fh, &old_date, &old_time );
   system("dir test.dat");
}


Additional reference words: 5.10 6.00 6.00a 6.00ax 7.00 1.00 1.50
KBCategory: kbprg kbprb
KBSubcategory: CRTIss
Keywords : kb16bitonly


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 17, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.