By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,505 Members | 1,034 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,505 IT Pros & Developers. It's quick & easy.

Deleting All Selected Checked files

P: n/a
Thank you in advance for any and all assistance. I have an application that
pulls files, folders and registry keys of installed programs. I'm wanting to
with a context menu selection of "Delete Selected", delete "ALL" of the
checked selected files, folders, registry keys. Can someone show me some code
to do this please?
Jun 28 '06 #1
Share this Question
Share on Google+
7 Replies


P: n/a

eSolTec wrote:
Thank you in advance for any and all assistance. I have an application that
pulls files, folders and registry keys of installed programs. I'm wanting to
with a context menu selection of "Delete Selected", delete "ALL" of the
checked selected files, folders, registry keys. Can someone show me some code
to do this please?


I don't have the time to enter a bunch of code, but basically you can
use the File.Delete method to delete files, Directory.Delete method to
delete folders, and the RegistryKey.DeleteValue,
RegistryKey.DeleteSubKey or RegistryKey.DeleteSubKeyTree (depending on
your needs) to delete registry entries.

Help has samples for all.

Jun 28 '06 #2

P: n/a
Zack,

thank you for your reply, but I'm using a treeview with an array in it and
the RegistryKey.Delete from MyComputer didn't work. So I would appreciate
someone either taking the time to show me some code for deleting files,
folders and registry keys. Thank you again for any and all assistance.

"za***@construction-imaging.com" wrote:

eSolTec wrote:
Thank you in advance for any and all assistance. I have an application that
pulls files, folders and registry keys of installed programs. I'm wanting to
with a context menu selection of "Delete Selected", delete "ALL" of the
checked selected files, folders, registry keys. Can someone show me some code
to do this please?


I don't have the time to enter a bunch of code, but basically you can
use the File.Delete method to delete files, Directory.Delete method to
delete folders, and the RegistryKey.DeleteValue,
RegistryKey.DeleteSubKey or RegistryKey.DeleteSubKeyTree (depending on
your needs) to delete registry entries.

Help has samples for all.

Jun 28 '06 #3

P: n/a
Zacks,

I have a Treeview (array list) of items that are registry keys, file names,
folder names that I wish to programmatically delete from their locations. Any
help for code would be greatly appreicated. Most are Registry Keys that I
wish to programmatically delete. I have looked at System.IO and also the
RegistryKey.Delete in the MyComputer Class and nothing so far has worked.

"za***@construction-imaging.com" wrote:

eSolTec wrote:
Thank you in advance for any and all assistance. I have an application that
pulls files, folders and registry keys of installed programs. I'm wanting to
with a context menu selection of "Delete Selected", delete "ALL" of the
checked selected files, folders, registry keys. Can someone show me some code
to do this please?


I don't have the time to enter a bunch of code, but basically you can
use the File.Delete method to delete files, Directory.Delete method to
delete folders, and the RegistryKey.DeleteValue,
RegistryKey.DeleteSubKey or RegistryKey.DeleteSubKeyTree (depending on
your needs) to delete registry entries.

Help has samples for all.

Jun 28 '06 #4

P: n/a
Try something like :
My.Computer.Registry.CurrentUser.DeleteSubKeyTree( "Software\MyCompany")

My.Computer.FileSystem.DeleteDirectory("c:\MyDirec tory",
FileIO.DeleteDirectoryOption.DeleteAllContents)

Generally it's always better that YOU show us what you do. For example my
first thought would be that you try to delete something you are not allowed
to delete (in which case our code wouldn't work better, also we could
provide VB2005 code when you are using VB 2003).

Also please always include an accurate description of the result you have
instead of just saying it didn't work...

--
Patrice

"eSolTec, Inc. 501(c)(3)" <eS*************@discussions.microsoft.com> a
écrit dans le message de news:
66**********************************@microsoft.com...
Zack,

thank you for your reply, but I'm using a treeview with an array in it and
the RegistryKey.Delete from MyComputer didn't work. So I would appreciate
someone either taking the time to show me some code for deleting files,
folders and registry keys. Thank you again for any and all assistance.

"za***@construction-imaging.com" wrote:

eSolTec wrote:
> Thank you in advance for any and all assistance. I have an application
> that
> pulls files, folders and registry keys of installed programs. I'm
> wanting to
> with a context menu selection of "Delete Selected", delete "ALL" of the
> checked selected files, folders, registry keys. Can someone show me
> some code
> to do this please?


I don't have the time to enter a bunch of code, but basically you can
use the File.Delete method to delete files, Directory.Delete method to
delete folders, and the RegistryKey.DeleteValue,
RegistryKey.DeleteSubKey or RegistryKey.DeleteSubKeyTree (depending on
your needs) to delete registry entries.

Help has samples for all.

Jun 28 '06 #5

P: n/a
Patrice,

Thank you for your tips. I greatly appreciate it.

VB 2005
Treeview: tv_Results
Code:
If MessageBox.Show("Delete all selected registry keys?",
"Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question,
MessageBoxDefaultButton.Button2) = Windows.Forms.DialogResult.Yes Then
Dim FileList As ArrayList
My.Computer.Registry.CurrentUser.DeleteSubKey(File List.ToString)

End If

Most of the keys are from programs that would be considered rogue or stuborn
to find an uninstaller or to uninstall from a computer. I'm building a tech
tool for my non-profit organization. Using messagebox to confirm the delete
first as you can see.

"Patrice" wrote:
Try something like :
My.Computer.Registry.CurrentUser.DeleteSubKeyTree( "Software\MyCompany")

My.Computer.FileSystem.DeleteDirectory("c:\MyDirec tory",
FileIO.DeleteDirectoryOption.DeleteAllContents)

Generally it's always better that YOU show us what you do. For example my
first thought would be that you try to delete something you are not allowed
to delete (in which case our code wouldn't work better, also we could
provide VB2005 code when you are using VB 2003).

Also please always include an accurate description of the result you have
instead of just saying it didn't work...

--
Patrice

"eSolTec, Inc. 501(c)(3)" <eS*************@discussions.microsoft.com> a
écrit dans le message de news:
66**********************************@microsoft.com...
Zack,

thank you for your reply, but I'm using a treeview with an array in it and
the RegistryKey.Delete from MyComputer didn't work. So I would appreciate
someone either taking the time to show me some code for deleting files,
folders and registry keys. Thank you again for any and all assistance.

"za***@construction-imaging.com" wrote:

eSolTec wrote:
> Thank you in advance for any and all assistance. I have an application
> that
> pulls files, folders and registry keys of installed programs. I'm
> wanting to
> with a context menu selection of "Delete Selected", delete "ALL" of the
> checked selected files, folders, registry keys. Can someone show me
> some code
> to do this please?

I don't have the time to enter a bunch of code, but basically you can
use the File.Delete method to delete files, Directory.Delete method to
delete folders, and the RegistryKey.DeleteValue,
RegistryKey.DeleteSubKey or RegistryKey.DeleteSubKeyTree (depending on
your needs) to delete registry entries.

Help has samples for all.


Jun 28 '06 #6

P: n/a
Just print out what is returned by FileList.ToString. You'll see this is not
what you expect (it prints out the class name).

(plus FileList is empty and I'm not sure what a FileList have to do with
registry key names but this is not the problem for now).

As you see we would never have spotted this without seeing YOUR code...

Hope it helps.

---
Patrice

"eSolTec, Inc. 501(c)(3)" <eS*************@discussions.microsoft.com> a
écrit dans le message de news:
5B**********************************@microsoft.com...
Patrice,

Thank you for your tips. I greatly appreciate it.

VB 2005
Treeview: tv_Results
Code:
If MessageBox.Show("Delete all selected registry keys?",
"Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question,
MessageBoxDefaultButton.Button2) = Windows.Forms.DialogResult.Yes Then
Dim FileList As ArrayList

My.Computer.Registry.CurrentUser.DeleteSubKey(File List.ToString)

End If

Most of the keys are from programs that would be considered rogue or
stuborn
to find an uninstaller or to uninstall from a computer. I'm building a
tech
tool for my non-profit organization. Using messagebox to confirm the
delete
first as you can see.

"Patrice" wrote:
Try something like :
My.Computer.Registry.CurrentUser.DeleteSubKeyTree( "Software\MyCompany")

My.Computer.FileSystem.DeleteDirectory("c:\MyDirec tory",
FileIO.DeleteDirectoryOption.DeleteAllContents)

Generally it's always better that YOU show us what you do. For example
my
first thought would be that you try to delete something you are not
allowed
to delete (in which case our code wouldn't work better, also we could
provide VB2005 code when you are using VB 2003).

Also please always include an accurate description of the result you have
instead of just saying it didn't work...

--
Patrice

"eSolTec, Inc. 501(c)(3)" <eS*************@discussions.microsoft.com> a
écrit dans le message de news:
66**********************************@microsoft.com...
> Zack,
>
> thank you for your reply, but I'm using a treeview with an array in it
> and
> the RegistryKey.Delete from MyComputer didn't work. So I would
> appreciate
> someone either taking the time to show me some code for deleting files,
> folders and registry keys. Thank you again for any and all assistance.
>
> "za***@construction-imaging.com" wrote:
>
>>
>> eSolTec wrote:
>> > Thank you in advance for any and all assistance. I have an
>> > application
>> > that
>> > pulls files, folders and registry keys of installed programs. I'm
>> > wanting to
>> > with a context menu selection of "Delete Selected", delete "ALL" of
>> > the
>> > checked selected files, folders, registry keys. Can someone show me
>> > some code
>> > to do this please?
>>
>> I don't have the time to enter a bunch of code, but basically you can
>> use the File.Delete method to delete files, Directory.Delete method to
>> delete folders, and the RegistryKey.DeleteValue,
>> RegistryKey.DeleteSubKey or RegistryKey.DeleteSubKeyTree (depending on
>> your needs) to delete registry entries.
>>
>> Help has samples for all.
>>
>>


Jun 28 '06 #7

P: n/a

eSolTec wrote:
Patrice,

Thank you for your tips. I greatly appreciate it.

VB 2005
Treeview: tv_Results
Code:
If MessageBox.Show("Delete all selected registry keys?",
"Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question,
MessageBoxDefaultButton.Button2) = Windows.Forms.DialogResult.Yes Then
Dim FileList As ArrayList
My.Computer.Registry.CurrentUser.DeleteSubKey(File List.ToString)

End If
FileList is an arraylist. DeleteSubKey takes a single sub key name in a
string. If the FileList array contains a list of string values that
represent the names of sub keys to delete, something this should work:

Dim sFile as String

For Each sFile in FileList
My.Computer.Registry.CurrentUser.DeleteSubKey(sFil e)
Next


Most of the keys are from programs that would be considered rogue or stuborn
to find an uninstaller or to uninstall from a computer. I'm building a tech
tool for my non-profit organization. Using messagebox to confirm the delete
first as you can see.

"Patrice" wrote:
Try something like :
My.Computer.Registry.CurrentUser.DeleteSubKeyTree( "Software\MyCompany")

My.Computer.FileSystem.DeleteDirectory("c:\MyDirec tory",
FileIO.DeleteDirectoryOption.DeleteAllContents)

Generally it's always better that YOU show us what you do. For examplemy
first thought would be that you try to delete something you are not allowed
to delete (in which case our code wouldn't work better, also we could
provide VB2005 code when you are using VB 2003).

Also please always include an accurate description of the result you have
instead of just saying it didn't work...

--
Patrice

"eSolTec, Inc. 501(c)(3)" <eS*************@discussions.microsoft.com> a
écrit dans le message de news:
66**********************************@microsoft.com...
Zack,

thank you for your reply, but I'm using a treeview with an array in it and
the RegistryKey.Delete from MyComputer didn't work. So I would appreciate
someone either taking the time to show me some code for deleting files,
folders and registry keys. Thank you again for any and all assistance.

"za***@construction-imaging.com" wrote:

>
> eSolTec wrote:
> > Thank you in advance for any and all assistance. I have an application
> > that
> > pulls files, folders and registry keys of installed programs. I'm
> > wanting to
> > with a context menu selection of "Delete Selected", delete "ALL" of the
> > checked selected files, folders, registry keys. Can someone show me
> > some code
> > to do this please?
>
> I don't have the time to enter a bunch of code, but basically you can
> use the File.Delete method to delete files, Directory.Delete method to
> delete folders, and the RegistryKey.DeleteValue,
> RegistryKey.DeleteSubKey or RegistryKey.DeleteSubKeyTree (depending on
> your needs) to delete registry entries.
>
> Help has samples for all.
>
>




Jun 28 '06 #8

This discussion thread is closed

Replies have been disabled for this discussion.