Click here to Skip to main content
Licence 
First Posted 23 Jan 2005
Views 50,350
Downloads 750
Bookmarked 30 times

Folder utilities

By Dudi Avramov | 31 Jan 2005
Folder utilities such as creating, removing, copying folders and getting folder's space.
7 votes, 35.0%
1
3 votes, 15.0%
2
1 vote, 5.0%
3
4 votes, 20.0%
4
5 votes, 25.0%
5
2.29/5 - 20 votes
μ 2.29, σa 2.97 [?]

Introduction

The CreateDirectory WIN32 API lets us create a folder. However, this function will succeed only if the parent folder exists. For example, creating a folder C:\AA\BB\CC\DD succeeds only if the parent folder C:\AA\BB\CC exists. Thus, CFolderUtils::CreateFolder solves that problem by creating the parent folders and then the specified folder itself.

The DeleteDirectory WIN32 API will fail to delete a folder as long there are sub-folders for that one. Thus, CFolderUtils::RemoveFolder solves that problem by removing recursively the sub-folders and after that the specified folder.

CFolderUtils::GetSpace recursively calculates a folder size.

CFolderUtils::CopyFolder uses SHFileOperation for copying a folder along with its sub-folders.

Whole four functions are implemented in FolderUtils.h as static functions to CFolderUtils.

Example

#include "FolderUtils.h"
void main()
{
    CFolderUtils::CreateFolder("C:\\AA\\BB\\CC\\DD");
    int Size = CFolderUtils::GetSize("C:\\AA");
}

History

  • 1-Feb-2005 - Fixed a bug in CreateFolder function.
  • 2-Feb-2005 - Fixed a bug in GetSpace that discarded folders that begin with "." and add a UNICODE support in RemoveFolder.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Dudi Avramov

Web Developer

Israel Israel

Member


Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
QuestionWhat about '/' ? Pinmemberjolindien0:33 18 Oct '07  
AnswerRe: What about '/' ? Pinmemberjolindien1:02 18 Oct '07  
GeneralPerfect! Pinmemberflippydeflippydebop10:53 2 Aug '07  
QuestionCopyFolder() Uses Literals - CString vars won't work? Pinmemberalan939:17 7 Feb '07  
AnswerRe: CopyFolder() Uses Literals - CString vars won't work? PinmemberDudi Avramov23:32 7 Feb '07  
GeneralRe: CopyFolder() Uses Literals - CString vars won't work? Pinmemberalan932:59 8 Feb '07  
GeneralRe: CopyFolder() Uses Literals - CString vars won't work? PinmemberDudi Avramov23:14 10 Feb '07  
QuestionWill it work for Poket PCs with Windows CE 5.0? PinmemberMaheshKalose22:18 10 Nov '06  
Jokeis Good PinmemberVladmorosan21:33 23 Mar '06  
Generalnot bad, but... PinmemberS.Cartwright22:09 8 May '05  
GeneralRe: not bad, but... PinmemberDudi Avramov22:51 9 May '05  
GeneralSome issues that need to be addressed Pinmember.:floyd:.16:36 1 Feb '05  
GeneralRe: Some issues that need to be addressed PinmemberDudi Avramov21:44 1 Feb '05  
QuestionDependencies? PinmemberDon Clugston20:53 24 Jan '05  
AnswerRe: Dependencies? Pinmemberrusseller11:15 23 Nov '05  
Generalusefull code Pinmembersudhir mangla19:01 24 Jan '05  
GeneralYou should reconsider some methods... PinmemberMarkus Hlacer5:28 24 Jan '05  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web04 | 2.5.120210.1 | Last Updated 1 Feb 2005
Article Copyright 2005 by Dudi Avramov
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid