I'm using Visual Studio .NET 2003. I have a folder with sub-folders
and files. I would like to know if there is a way to only delete the
empty folders.
For example, I have
C:\FolderA\FolderB // empty folder
C:\FolderA\FolderC
C:\FolderA\FolderD
C:\FolderA\FileE
C:\FolderA\FileF
I only want to delete FolderB. Is there a way to perhaps, get the
attributes to indicate that a particular file is actually a folder,
then go into the folder to see if there are any files in it?
Thank you.
Regards,
Rayne
Well, there is GetFileAttributes[Ex] function.
> then go into the folder to see if there are any files in it?
You can use FindFirstFile, FindNextFile in order to enumerate
folder's contents.
HTH
Alex
Or, you can just go ahead and call RemoveDirectory. The call will fail if the path doesn't specify a directory, or if the directory is not empty.
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not necessarily a good idea. It is hard to be sure where they are going to land, and it could be dangerous sitting under them as they fly overhead. -- RFC 1925