473,326 Members | 2,061 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,326 software developers and data experts.

Search and delete directories

How do I search for a directory on a windows xp machine
and delete the directory including all subfolders and
files in them?
Nov 20 '05 #1
2 1106
* "Philip Wagenaar" <p.********@accon.nl> scripsit:
How do I search for a directory on a windows xp machine
and delete the directory including all subfolders and
files in them?


Scanning a directory:

<http://www.mvps.org/dotnet/dotnet/samples/filesystem/downloads/RecursiveFileScan.zip>

Deleting:

'System.IO.Directory.Delete(<path>, True)'.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #2
Hi,

as far as I understand U loop through the folders for foldername and when
found, delete the folder including subfolders See code below. try it but be
careful cause it deletes without asking

LoopFolders ("C:\Temp")

Private Sub LoopFolders(ByVal nod As String)
Dim strPath As String = nod
Dim strDir As String

With nod
For Each strDir In Directory.GetDirectories(strPath)
' Path.GetFileName returns just the file name portion of the full
path returned from the GetDirectories method.
if strDir = SEARCHED_FOLDER then
strPath =
Directory.Delete(strPath, true) ' CAREFUL this doesn't ask
for confirmation it simply delete recursivly the folder and contents
end if
Next
End With
End Sub

--
Yours
/ Anders Sundberg


"Philip Wagenaar" <p.********@accon.nl> wrote in message
news:08****************************@phx.gbl...
How do I search for a directory on a windows xp machine
and delete the directory including all subfolders and
files in them?

Nov 20 '05 #3

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

Similar topics

11
by: Ben | last post by:
Greetings, I am looking for a way to search for and delete files based on a pattern mask. For example, the search method would find all files matching a certain pattern containing wildcards (e.g....
3
by: Stephen Ferg | last post by:
I need a little help here. I'm developing some introductory material on Python for non-programmers. The first draft includes this statement. Is this correct? ...
3
by: Charles Herman | last post by:
I am using the following flags for the g++ command -I/usr/local/gcc-3.3/include/c++/3.3 -I/usr/local/include/g++-3 But istead of searching the first directory first, it searches the second...
2
by: Patrick | last post by:
Are the differences between a search engine, a subject directory and a meta search engine significant for an ebusiness web site owner? A meta search engine merely uses ordinary existing search...
9
by: Paul | last post by:
I'm trying to make get my app to delete all the files in a specified folder and all the files within the folders of the specified folder. e.g. Folder 1 contains three files (File1, File2, File3)...
10
by: Dan | last post by:
Hi - I'm about a week into learning VB.NET, and I'm finding I can't delete any of the VB.NET directory structures that contain my test projects I've been trying to create. I've never seen this...
2
by: nospam | last post by:
I am writing this app in .net 2003 since all machines don't have 2.0 framework. I am trying to delete old profiles, but I am getting access denied or file in use errors. A lot of these files I am...
1
by: Petyr David | last post by:
Current: web page has hard coded directories (using checkboxes) user may choose to search for files matching a pattern they enter in text box. Perl is used to search for files and to format HTML...
30
by: Jrdman | last post by:
hi there can any one write a C code that search for files in a directory without using the windows apis(FindFirstFile() and FindNextFile()) or even has a small idea on how to do that. thanks.
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.