zoukankan      html  css  js  c++  java
  • 删除文件夹下所有文件

    // 删除文件夹下的所有文件 VC6.0下测试通过
    BOOL DelDirFiles(CString strPath)
    {
    WIN32_FIND_DATA wfd;
    HANDLE hFind;
    CString strFullPath;
    CString strFindFilter;
    DWORD dwAttributes = 0;

    strFindFilter = strPath + _T("\*.*");
    hFind = FindFirstFile(strFindFilter, &wfd);
    if (INVALID_HANDLE_VALUE == hFind)
    {
    return FALSE;
    }

    do
    {
    if (_tcscmp(wfd.cFileName, _T(".")) == 0 ||
    _tcscmp(wfd.cFileName, _T("..")) == 0 )
    {
    continue;
    }

    strFullPath = strPath + _T("\") + wfd.cFileName;
    //去掉只读属性
    dwAttributes = GetFileAttributes(strFullPath);
    if (dwAttributes & FILE_ATTRIBUTE_READONLY)
    {
    dwAttributes &= ~FILE_ATTRIBUTE_READONLY;
    SetFileAttributes(strFullPath, dwAttributes);
    }

    if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
    {
    DelDirFiles(strFullPath);
    RemoveDirectory(strFullPath);
    }
    else
    {
    DeleteFile(strFullPath);
    }
    }while (FindNextFile(hFind, &wfd));

    FindClose(hFind);

    return TRUE;
    }

  • 相关阅读:
    对于“口袋精灵”单元测试
    12-17:项目进度
    12-15:项目进度
    12-14:项目进度
    12-13:项目进度
    12-12:项目进度
    12-11:项目进度
    12-10:项目进度
    12-9:项目进度
    12-6:项目进度
  • 原文地址:https://www.cnblogs.com/zengjunde/p/3485383.html
Copyright © 2011-2022 走看看