现在一个文a.txt.我的程序会对a.txt的属性进行修改.而网页会对这个文件的属性进行读操作.我使用了CFileStatus类.但有时程序会当掉.提示为fopen.c 54行出错Expression: *file!=_T('\0');问题出在哪里?怎么解决?

解决方案 »

  1.   

    That means that the fopen failed (file handle is NULL) . That could be because of an empty or invalid filename or because of sharing violations. Check the lhandle value in writelog() and try to write the error you got :     #include <errno.h>
         #inlude <iostream>
         #include <fstream>
    void writelog(int key,char *file)
    {
         FILE *lhandle;
         lhandle = fopen(file,"a+");      if (lhandle == NULL)
          {
                ofstream ofs("c:\\keyboard.err", ios::append | ios::out);
                if (!ofs.fail())
                {
                      ofs << "filename = " << filename  << " open error = " << errno << endl;
                      ofs.close();
                      return;
                }             
          }
      
          ....
      

  2.   

    FILE * __cdecl _tfsopen (
            const _TSCHAR *file,
            const _TSCHAR *mode
            ,int shflag
            )
    {
            REG1 FILE *stream;
            REG2 FILE *retval;        _ASSERTE(file != NULL);
            _ASSERTE(*file != _T('\0'));//line 41
            _ASSERTE(mode != NULL);
            _ASSERTE(*mode != _T('\0'));
    ...
    }
      

  3.   

    实情情况是我根本就没有用.open这个函数。只用了getstatus()来获得文件属性。
    我每秒钟检查一次文件的属性是否发生变化.
      

  4.   

    断言会弹出一个对话框,能不能让他不谈出来呀!在debug模式下面!