How to delete all the files in the specified folder?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

by meanse of System.IO namespace?
(The task is being doing easily by screepting runtime.)

Thanks in advance.
 
string [] fileEntries = Directory.GetFiles(targetDirectory);
foreach(string fileName in fileEntries)
{
File.Delete(Path.Combine(targetDirectory, fileName));
}
 
I said "all the files in the specified folder", that means the file names are
unknown.
It must be something like for each... in the folder.
Is it possible?

Thanks in advance.


Vadym Stetsyak said:
string [] fileEntries = Directory.GetFiles(targetDirectory);
foreach(string fileName in fileEntries)
{
File.Delete(Path.Combine(targetDirectory, fileName));
}

--
Vadym Stetsyak aka Vadmyst
http://vadmyst.blogspot.com

Ivan Abramov said:
by meanse of System.IO namespace?
(The task is being doing easily by screepting runtime.)

Thanks in advance.
 
Oh, sorry, Vadym,
I'm blind, of cause, it's ok.

Greate thanks.


Vadym Stetsyak said:
string [] fileEntries = Directory.GetFiles(targetDirectory);
foreach(string fileName in fileEntries)
{
File.Delete(Path.Combine(targetDirectory, fileName));
}

--
Vadym Stetsyak aka Vadmyst
http://vadmyst.blogspot.com

Ivan Abramov said:
by meanse of System.IO namespace?
(The task is being doing easily by screepting runtime.)

Thanks in advance.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top