Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Deleting only folders

0 views
Skip to first unread message

Rayne

unread,
Dec 28, 2009, 5:09:57 AM12/28/09
to
Hi all,

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

Alex Blekhman

unread,
Dec 28, 2009, 5:58:56 AM12/28/09
to
"Rayne" wrote:
> Is there a way to perhaps, get the attributes to indicate that a
> particular file is actually a folder,

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

Igor Tandetnik

unread,
Dec 28, 2009, 10:30:47 AM12/28/09
to

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

0 new messages