473,396 Members | 1,914 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Delete All Files in a Directory

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
Nov 17 '05 #1
4 17417
Jeffrey,

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

Nov 17 '05 #2
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.

--
Cheers,
Rahul Anand

"Jeffrey" wrote:
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

Nov 17 '05 #3
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!
"Visually Seen #" <al*****************@gmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
Jeffrey,

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

Nov 17 '05 #4
"Jeffrey" <JT*@nospam.net> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
And, why the attitude ("Excuse me")? Did I offend you personally in some
way?


Forget him - he's an idiot.

Anyway, to answer your question:
http://msdn.microsoft.com/library/de...eletetopic.asp
Nov 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Jobs | last post by:
Hello All, I want to delete all files in a directory. I am making a backup copy of all files in the directories say c:\abc by reading and writing to a file. After making a backup copy I want to...
1
by: Earl Teigrob | last post by:
Does someone have or know of an algorythm (method) that will delete all files under a give directory and its subdirectories based on a wildcard mask? I can use this for one directory for each...
12
by: Lucas Tam | last post by:
I have a very simple loop: If (Directory.Exists(tempDirectory)) Then Try Dim Files() As String = Directory.GetFiles(tempDirectory) 'Clear out directory For Each Filename As String In Files...
3
by: Arpan | last post by:
A Form has a FileUpload, 2 Buttons & a TextBox web server controls. Using the FileUpload control, I want to give users the provision to move & delete files that DO NOT exist in C:\Inetpub\wwwroot...
7
by: Anil Gupte | last post by:
Private Sub mnu2Exit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnu2Exit.Click Dim fDir As String = Path.GetDirectoryName(L3Global.VideoFileName) ...
1
by: jlskutt | last post by:
I'm getting an odd Exception thrown using Directory.Delete. Directory.Delete(publicData + "Chatrooms/K" + kingd, true); Directory.Delete(publicData + "Kingdoms/" + kingd, true); There are...
24
by: biganthony via AccessMonster.com | last post by:
Hi, I have the following code to select a folder and then delete it. I keep getting a Path/File error on the line that deletes the actual folder. The line before that line deletes the files in...
5
by: fniles | last post by:
I am using VB.NET 2005. When I try to delete a folder that has files underneath it, it gave me "the directory is not empty" error. f = New IO.DirectoryInfo("C:\myfolder") If f.Exists Then...
0
by: wolfsbane | last post by:
Alright, here it is I am trying to write a win32 app in VB 2005 to clean up user's profiles. everything works correctly except for the Delete("directory", True) statement. I get a...
2
Airslash
by: Airslash | last post by:
Hi, I'm currently working on a function to delete a folder and its files + subfolders. The function currently works for the target folder, but refuses to delete the subfolders and files in the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.