zoukankan      html  css  js  c++  java
  • MFC

     1 // 删除指定的文件夹
     2 void DeleteDirectory(CString strDir)
     3 {
     4     if (strDir.IsEmpty())
     5     {
     6         RemoveDirectory(strDir);
     7         return;
     8     }
     9 
    10     //首先删除文件及子文件夹 
    11     CFileFind   ff;
    12     BOOL bFound = ff.FindFile(strDir + _T("\*"), 0);
    13     while (bFound)
    14     {
    15         bFound = ff.FindNextFile();
    16         if (ff.GetFileName() == _T(".") || ff.GetFileName() == _T(".."))        continue;
    17 
    18         //去掉文件(夹)只读等属性 
    19         SetFileAttributes(ff.GetFilePath(), FILE_ATTRIBUTE_NORMAL);
    20         if (ff.IsDirectory())
    21         {
    22             //递归删除子文件夹 
    23             DeleteDirectory(ff.GetFilePath());
    24             RemoveDirectory(ff.GetFilePath());
    25         }
    26         else
    27         {
    28             DeleteFile(ff.GetFilePath());   //删除文件 
    29         }
    30 
    31     }
    32 
    33     ff.Close();
    34 
    35     //然后删除该文件夹 
    36     RemoveDirectory(strDir);
    37 }
  • 相关阅读:
    开发day7
    开发day6
    开发day5
    开发day4
    开发day3
    开发day2
    开发day1
    假期学习2/8
    什么是栈帧
    JDK、JRE和JVM到底是什么
  • 原文地址:https://www.cnblogs.com/DuanLaoYe/p/5399337.html
Copyright © 2011-2022 走看看