zoukankan      html  css  js  c++  java
  • MFC 相关文件夹、文件操作

    //关于文件(夹)操作,可以参考下SHFileOperation这个外壳函数,貌似可以显示进度条。
    以下没有使用SHFileOperation
    //删除一个文件夹下的所有内容
    void myDeleteDirectory(CString directory_path)
    {    
        CFileFind finder; 
        CString path; 
        path.Format("%s/*.*",directory_path); 
        BOOL bWorking = finder.FindFile(path); 
        while(bWorking){ 
            bWorking = finder.FindNextFile(); 
            if(finder.IsDirectory() && !finder.IsDots()){//处理文件夹 
                myDeleteDirectory(finder.GetFilePath()); //递归删除文件夹 
                RemoveDirectory(finder.GetFilePath()); //删除文件夹,只能删除空的文件夹
            } 
            else{//处理文件 
                DeleteFile(finder.GetFilePath());//删除文件
            } 
        } 
    }
    PathIsDirectory(path)//判读path是否为文件夹
    PathFileExists(path)//判读path是否存在
    CreateDirectory(newPath,NULL)//创建一个文件夹
    CopyFile(srcfile,dstfile,false)//复制文件

  • 相关阅读:
    Solution to LeetCode Problem Set
    《Cracking the Coding Interview》读书笔记
    诗词收集——用于人文素养扫盲
    2015年清华大学计算机系考研总结
    编程知识大杂烩
    hihoCoder 1175:拓扑排序二
    Hackerrank
    Hackerrank
    LeetCode
    LeetCode
  • 原文地址:https://www.cnblogs.com/coolbear/p/3458125.html
Copyright © 2011-2022 走看看