473,769 Members | 7,320 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1123
* "Philip Wagenaar" <p.********@acc on.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/RecursiveFileSc an.zip>

Deleting:

'System.IO.Dire ctory.Delete(<p ath>, 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(ByV al nod As String)
Dim strPath As String = nod
Dim strDir As String

With nod
For Each strDir In Directory.GetDi rectories(strPa th)
' Path.GetFileNam e returns just the file name portion of the full
path returned from the GetDirectories method.
if strDir = SEARCHED_FOLDER then
strPath =
Directory.Delet e(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.********@acc on.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
15657
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. *FILE29*.TXT). I'm looking for a way to do this in either Visual Basic or C(++). Thanks!
3
9734
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? ----------------------------------------------------------------- When loading modules, Python looks for modules in the following places in the following order:
3
9243
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 directory first. When I interchange the directories, it still searches /usr/local/include/g++-3 first. How can I force it to search in the order I want? When I do not include any -I flag in the g++ commnand, it searches only
2
11845
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 engines. A subject directory classifies websites into some category. Could anyone point me towards the differences between these three that are significant for an ebusiness web site owner?
9
8336
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) and two folders (Subfolder 1, Subfolder 2). .......I need to delete File1, File2, File3. Subfolder 1 contains FileA. .......Need to delete FileA. Subfolder 2 contains FileB, FileC, FileD.
10
2924
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 before... Whenever I try, it says something like "access is denied" and "make sure the disk is not write-protected and file is not currently in use". Is there something VB.NET does that would cause this? I'm starting to build up a bunch of test...
2
21880
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 able to delete in Windows Explorer. The app is getting launched using the System account, so there is plenty of rights to delete the files. I have tried the following: Recursive delete of every file using Kill()
1
1837
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 output. Desired: dynamically created group of checkboxes upon opening web page. My initial idea is to have user run separate Perl script to find
30
2076
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
9589
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10216
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10049
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9865
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7413
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5309
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.