CStdioFile FileSource;
if( FileSource.Open("\\\nt\\我的数据\\2003.txt",CFile::modeRead));
{
MessageBox("不能打开源文件","提示");
return;
}//在执行上述时已经登陆进网络中.
//其中nt是局域网上的一个共享计算机名,我用我的账户进入后,在win系统中可以随便修改,但用vc写上述句子时,却总是出错!"不能打开源文件",文件名什么都是对的,为什么?
但我用映射该路径为本地磁盘以后,象类似打开本地磁盘一样的路径,就可以!          难道上面不能直接打开?     请说明,谢谢!

解决方案 »

  1.   

    if( FileSource.Open("\\\nt\\我的数据\\2003.txt",CFile::modeRead));
    尾巴的 分号 去掉。
      

  2.   

    LPVOID lpMsgBuf;
    FormatMessage( 
        FORMAT_MESSAGE_ALLOCATE_BUFFER | 
        FORMAT_MESSAGE_FROM_SYSTEM | 
        FORMAT_MESSAGE_IGNORE_INSERTS,
        NULL,
        GetLastError(),
        MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
        (LPTSTR) &lpMsgBuf,
        0,
        NULL 
    );
    // Process any inserts in lpMsgBuf.
    // ...
    // Display the string.
    MessageBox( NULL, (LPCTSTR)lpMsgBuf, "Error", MB_OK | MB_ICONINFORMATION );
    // Free the buffer.
    LocalFree( lpMsgBuf );使用如上代码察看错误信息
      

  3.   

    还有就是CFile::Open的返回值是这样描述的
    Nonzero if the open was successful; otherwise 0. The pError parameter is meaningful only if 0 is returned