请教个问题:我想实现如果一个csv文件一发上变化,另一个应用程序就能得知,除了设置计时器不停的扫描之外有没有其他好一点的办法。
另,怎样才能得知这个csv文件发生了变化?

解决方案 »

  1.   

    你可以看看这个文件的一些信息,可以使用_stat 这个函数,_stat 也是一个结构,里面是文件的一些信息。#include <time.h>
    #include <sys/types.h>
    #include <sys/stat.h>
    #include <stdio.h>void main( void )
    {
       struct _stat buf;
       int result;
       char buffer[] = "A line to output";   /* Get data associated with "stat.c": */
       result = _stat( "stat.c", &buf );   /* Check if statistics are valid: */
       if( result != 0 )
          perror( "Problem getting information" );
       else
       {
          /* Output some of the statistics: */
          printf( "File size     : %ld\n", buf.st_size );
          printf( "Drive         : %c:\n", buf.st_dev + 'A' );
          printf( "Time modified : %s", ctime( &buf.st_atime ) );
       }
    }
      

  2.   

    应该用API中的文件系统通知函数。
      

  3.   

    http://www.china-askpro.com/msg33/qa46.shtml