Delete All Files in a Directory

  • Thread starter Thread starter Jeffrey
  • Start date Start date
J

Jeffrey

Is there an easy way to delete all files in a directory (i.e., without
explicitly looping through all file names and individuall deleting each
file)?

Thanks
 
Jeffrey,

Excuse me, but this is a group on C#, not on general Windows.
Just delete the folder
 
Hi Jeffrey,

As per my knowledge you can not delete all files in a folder
programmatically using .net base class library.

But it is pretty easy to *foreach* files returned by Directory.GetFiles and
deleting using File.Delete.

If you really want to delete all files with one command (for some reason)
then probably you need to fire a DOS command by spawning a DOS Shell.

Hope it will help.
 
What in the original post makes you think this question is unrelated to C#
and is instead about "general Windows"? It can easily be inferred from my
clarification in the OP (i.e....not looping..) that I'm writing some code
here... and that it's most likely in C# because the OP is posted in the C#
group. Geeze!

Your advice to delete the folder goes well beyond the scope of the original
objective which is specifically to delete all the files in a folder.

And, why the attitude ("Excuse me")? Did I offend you personally in some
way?

Wow!
 
Back
Top