MFC_VC++fopen_s打开网路路径文件,保存信息日志

fopen_s打开网路路径文件,保存信息日志

FILE *pFileHandle1 = NULL;
    try
    {
    
     if (_access("\\\\172.17.140.245\\dfnssawdata\\loger\\", 0) != 0)
        CreateDirectory(_T("\\\\172.17.140.245\\dfnssawdata\\"), NULL);
     sprintf_s(szLogFilePath, "\\\\172.17.140.245\\dfnssawdata\\loger\\%04d_%02d_%02d_%02d.log", sysTime.wYear, sysTime.wMonth, sysTime.wDay, sysTime.wHour);
     fopen_s(&pFileHandle1, szLogFilePath, "a+b");
     if (pFileHandle1 == NULL)
     {
        m_strLogList.RemoveAll();
        return;
     }
     pPos = m_strLogList.GetHeadPosition();
     while (pPos)
     {
        strLogInfo = m_strLogList.GetNext(pPos);
        fprintf_s(pFileHandle1, "%s\r\n", _bstr_t(strLogInfo).operator const char*());
     }
     m_strLogList.RemoveAll();
    fclose(pFileHandle1);
    }
    catch(CFileException ex1)
    {
        MessageBox(L"网络错误,无法访问172.17.140.245");
    }

    
欢迎讨论,相互学习。 txwtech@163.com
原文地址:https://www.cnblogs.com/txwtech/p/15565763.html