Deliting files from a letterbox in VB2008

Can you delete system files shown in a letterbox in VB2008?

  • (2 Pages)
  • +
  • 1
  • 2

23 Replies - 1724 Views - Last Post: 11 September 2009 - 01:11 AM Rate Topic: -----

#1 Roxor  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 3
  • View blog
  • Posts: 41
  • Joined: 27-August 09

Deliting files from a letterbox in VB2008

Post icon  Posted 27 August 2009 - 11:41 AM

Hi all,im new here :D
I have a serious problem,so i tought i can ask here.I'm only a BEGINER!
So,i looked on youtube,to make an anti-virus in Visual Basic(i then heard about VB2008:D).I maked a scan button,and putted some strings that will scan some computer's folders and show de detected viruses on a letterbox.
Now,i wonder if someone nows a way(code or not) to add a button that will delete all the files detected that are shown on that letterbox.I want not to delet them manualy,i want my small anti-virus to that that.IS THERE A WAY?
Thnx al lot!!!!!!!! :) :D :^:

Is This A Good Question/Topic? 0
  • +

Replies To: Deliting files from a letterbox in VB2008

#2 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2267
  • View blog
  • Posts: 9,482
  • Joined: 29-May 08

Re: Deliting files from a letterbox in VB2008

Posted 27 August 2009 - 12:37 PM

Dream.In.Code has a policy by which we prefer to see a good faith effort on your part before providing source code for homework assignments. Please post the code you have written in an effort to resolve the problem, and our members would be happy to provide some guidance. Be sure to include a description of any errors you are encountering as well.

Post your code like this: :code:

Thanks.
Was This Post Helpful? 0
  • +
  • -

#3 Roxor  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 3
  • View blog
  • Posts: 41
  • Joined: 27-August 09

Re: Deliting files from a letterbox in VB2008

Posted 27 August 2009 - 12:56 PM

[quote name='AdamSpeight2008' date='27 Aug, 2009 - 11:37 AM' post='748224']
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
FileSystem.FileExists("c:\Program Files\ACM") then listbox2.items.add ("Spyware.ACM")

The upper is the code for the button,down is the code for scanning the folders(ihave lots of this code in a button:D).
And this is the vido from youtube,on how to make it,sorry cause i can help so much:DTHNX.
http://www.youtube.c...I...PL&index=23
P.S.Error when i try to build the antivirus:
3xStatement is not valid in a namespace
1xIdentifier expected
Maybe you can help me with some coding,cause my AV isn't working :crazy: Thnx for the future helping :)
Was This Post Helpful? 0
  • +
  • -

#4 PDUNZ  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 43
  • View blog
  • Posts: 376
  • Joined: 17-July 09

Re: Deliting files from a letterbox in VB2008

Posted 27 August 2009 - 04:44 PM

Change the above to
If IO.File.Exists("c:\Program Files\ACM\FILETOLOCATE.EXT") Then ListBox2.Items.Add("Spyware.ACM") for locating files in a directory, or

If IO.Directory.Exists("c:\Program Files\ACM") Then ListBox2.Items.Add("Spyware.ACM") to locate a directory (which I presume is what your doing).

Now, you can use an array or such to add the directories or filenames, then loop through them and delete each one - thats if your not adding the directory names or filenames to a listbox.

To delete a File or Directory
		IO.File.Delete(filename) ' Delete File.
		IO.Directory.Delete(directory_name) ' Delete Directory.



If you get an error, add Imports System.IO.

This post has been edited by PDUNZ: 27 August 2009 - 07:11 PM

Was This Post Helpful? 0
  • +
  • -

#5 Roxor  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 3
  • View blog
  • Posts: 41
  • Joined: 27-August 09

Re: Deliting files from a letterbox in VB2008

Posted 28 August 2009 - 02:42 AM

Thnx a lot,i didn't tryed this but i'll try.JUst 2 problems:
1)I thought it'll be a way to delete al detected files in letterbox,with a single command,not to copy-paste every delete command and change the directory :( :unsure: .Isn't there a way to delete the detected files shown in the letterbox?Cause,maybe on the computer they're aren't all the folder(viruses) and it will erase nothing+i'll get an error.Thnx for the future posts for this problem.
2 and MOST IMPORTANT)Down is all the code i have on my AV project,because as i said upper,i get 4 big errors,and can't build the AV.Maybe you can help me change the code,or WTF:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
FileSystem.FileExists("c:\Program Files\180 SearchAssistant") then listbox1.items.add ("Adware.180Search")
FileSystem.FileExists("c:\Program Files\2Search") then listbox1.items.add ("Adware.2Search")
FileSystem.FileExists("c:\Program Files\5whgue21") then listbox1.items.add ("Adware.ClearSearch")
FileSystem.FileExists("c:\Program Files\AdStatComm.dll") then listbox1.items.add ("AutoUpdate(VX2)")
FileSystem.FileExists(" C:\Program Files\0er8k4va\0er8k4va.exe") then listbox1.items.add ("AutoUpdate(VX2)")
FileSystem.FileExists(" C:\WINDOWS\System32\Mkfxut.exe") then listbox1.items.add ("AutoUpdate(VX2)")
FileSystem.FileExists(" C:\WINDOWS\system32\pkdacs.exe") then listbox1.items.add ("AutoUpdate(VX2)")
FileSystem.FileExists(" C:\WINDOWS\System32\ywrqku.exe") then listbox1.items.add ("AutoUpdate(VX2)")
FileSystem.FileExists(" C:\windows\system32\msnavc32.exe") then listbox1.items.add ("AutoUpdate(VX2)")
FileSystem.FileExists(" C:\Program Files\AutoUpdate\AutoUpdate.exe") then listbox1.items.add ("AutoUpdate(VX2)")
FileSystem.FileExists(" C:\WINDOWS\System32\winntcreate.exe") then listbox1.items.add ("AutoUpdate(VX2)")
FileSystem.FileExists(" C:\WINDOWS\System32\vwix32.exe") then listbox1.items.add ("AutoUpdate(VX2)")
FileSystem.FileExists(" C:\WINDOWS\System32\sysmonnt.exe") then listbox1.items.add ("AutoUpdate(VX2)")
FileSystem.FileExists(" C:\WINDOWS\System32\winhcek32.exe") then listbox1.items.add ("AutoUpdate(VX2)")
FileSystem.FileExists(" C:\WINDOWS\System32\qlykdnb.dll") then listbox1.items.add ("AutoUpdate(VX2)")
FileSystem.FileExists(" C:\WINDOWS\System32\rypgvtoimrl.exe") then listbox1.items.add ("AutoUpdate(VX2)")
FileSystem.FileExists(" C:\WINDOWS\System32\spwgoc.exe ") then listbox1.items.add ("AutoUpdate(VX2)")
FileSystem.FileExists(" C:\windows\system32\msnavc32.exe") then listbox1.items.add ("AutoUpdate(VX2)")
FileSystem.FileExists(" C:\WINDOWS\System32\sysmonnt") then listbox1.items.add ("AutoUpdate(VX2)")
FileSystem.FileExists(" C:\Program Files\hpdll\hpdll.exe ") then listbox1.items.add ("AutoUpdate(VX2)")
FileSystem.FileExists(" C:\WINDOWS\System32\w?wexec.exe") then listbox1.items.add ("AutoUpdate(VX2)")
FileSystem.FileExists(" C:\WINDOWS\isrvs\ffisearch.exe") then listbox1.items.add ("AutoUpdate(VX2)")
FileSystem.FileExists("c:\Program Files\Autosearch.dll") then listbox1.items.add ("AutoUpdate(VX2)")
FileSystem.FileExists("c:\Program Files\Browser Pal") then listbox1.items.add ("Adware.BrowserPal")

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
FileSystem.FileExists("c:\Program Files\ACM") then listbox2.items.add ("Spyware.ACM")
FileSystem.FileExists("c:\Program Files\Activity Keylogger") then listbox2.items.add ("Spyware.ActivityKey")
FileSystem.FileExists("c:\Program Files\Activity Logger") then listbox2.items.add ("Spyware.ActivityLog")
FileSystem.FileExists("c:\Program Files\Actual Spy") then listbox2.items.add ("Spyware.ActualSpy")
FileSystem.FileExists("c:\Program Files\AdvSearch") then listbox2.items.add ("Spyware.ActualNames")
FileSystem.FileExists("c:\Program Files\AppsTraka") then listbox2.items.add ("Spyware.AppsTraka")
FileSystem.FileExists("c:\Program Files\Ardamax Keylogger") then listbox2.items.add ("Spyware.Ardakey.B.")
FileSystem.FileExists("c:\Program Files\Auto Keylogger") then listbox2.items.add ("Spyware.IkitecKL")
FileSystem.FileExists("c:\Program Files\BazookaBar") then listbox2.items.add ("Spyware.Bazookabar")
FileSystem.FileExists("c:\Program Files\Blackbox7") then listbox2.items.add ("Spyware.Blackbox")
FileSystem.FileExists("c:\Program Files\Blackbox7") then listbox2.items.add ("")



End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
FileSystem.FileExists("c:\Program Files\aolx") then listbox3.items.add ("Backdoor W32.Allim.B")
FileSystem.FileExists("c:\Program Files\Archive.exe") then listbox3.items.add ("Trojan.Dloadr-ABP")
FileSystem.FileExists("c:\Program Files\Archive.exe") then listbox3.items.add ("Trojan.Cmapp")
FileSystem.FileExists("c:\Program Files\BTV") then listbox3.items.add ("Breg_inst.exe")
End Sub
Class
End Class


Error 1 Statement is not valid in a namespace. C:\Documents and Settings\Doggy\My Documents\Visual Studio 2008\Projects\BoneScrapper Anti-Virus Beta\BoneScrapper Anti-Virus Beta\BoneScrapper Antivirus Beta.vb 2 1 BoneScrapper Anti-Virus Beta


Error 2 Statement is not valid in a namespace. C:\Documents and Settings\Doggy\My Documents\Visual Studio 2008\Projects\BoneScrapper Anti-Virus Beta\BoneScrapper Anti-Virus Beta\BoneScrapper Antivirus Beta.vb 30 1 BoneScrapper Anti-Virus Beta

Error 3 Statement is not valid in a namespace. C:\Documents and Settings\Doggy\My Documents\Visual Studio 2008\Projects\BoneScrapper Anti-Virus Beta\BoneScrapper Anti-Virus Beta\BoneScrapper Antivirus Beta.vb 47 1 BoneScrapper Anti-Virus Beta

Error 4 Identifier expected. C:\Documents and Settings\Doggy\My Documents\Visual Studio 2008\Projects\BoneScrapper Anti-Virus Beta\BoneScrapper Anti-Virus Beta\BoneScrapper Antivirus Beta.vb 53 5 BoneScrapper Anti-Virus Beta


I can't be more xplicite than this,so PLEAESE HELP.Thnx :^:
Was This Post Helpful? 0
  • +
  • -

#6 searockruz  Icon User is offline

  • D.I.C Regular

Reputation: 24
  • View blog
  • Posts: 460
  • Joined: 07-March 09

Re: Deliting files from a letterbox in VB2008

Posted 28 August 2009 - 03:32 AM

Are you sure you have added Imports System.IO namespace as PDUNZ has said
Was This Post Helpful? 0
  • +
  • -

#7 Roxor  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 3
  • View blog
  • Posts: 41
  • Joined: 27-August 09

Re: Deliting files from a letterbox in VB2008

Posted 28 August 2009 - 03:45 AM

Is it good what did i write there?I'm not sure :D :blink:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Imports System.IO 
IO.Directory.Delete("c:\Program Files\180 SearchAssistant") then listbox1.items.add ("Adware.180Search")

The heck with this anti-virus in VB
Was This Post Helpful? 0
  • +
  • -

#8 Roxor  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 3
  • View blog
  • Posts: 41
  • Joined: 27-August 09

Re: Deliting files from a letterbox in VB2008

Posted 28 August 2009 - 03:52 AM

I still get an error when entering the "Imports System.IO ",the hell.Someone please take a look again,at my code,and my errors(modified:D)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Imports System.IO 
IO.Directory.Delete("c:\Program Files\180 SearchAssistant") then listbox1.items.add ("Adware.180Search")
IO.Directory.Delete("c:\Program Files\2Search") then listbox1.items.add ("Adware.2Search")
IO.Directory.Delete("c:\Program Files\5whgue21") then listbox1.items.add ("Adware.ClearSearch")
IO.Directory.Delete("c:\Program Files\AdStatComm.dll") then listbox1.items.add ("AutoUpdate(VX2)")
IO.Directory.Delete(" C:\Program Files\0er8k4va\0er8k4va.exe") then listbox1.items.add ("AutoUpdate(VX2)")
IO.Directory.Delete(" C:\WINDOWS\System32\Mkfxut.exe") then listbox1.items.add ("AutoUpdate(VX2)")
IO.Directory.Delete(" C:\WINDOWS\system32\pkdacs.exe") then listbox1.items.add ("AutoUpdate(VX2)")
IO.Directory.Delete(" C:\WINDOWS\System32\ywrqku.exe") then listbox1.items.add ("AutoUpdate(VX2)")
IO.Directory.Delete(" C:\windows\system32\msnavc32.exe") then listbox1.items.add ("AutoUpdate(VX2)")
IO.Directory.Delete(" C:\Program Files\AutoUpdate\AutoUpdate.exe") then listbox1.items.add ("AutoUpdate(VX2)")
IO.Directory.Delete(" C:\WINDOWS\System32\winntcreate.exe") then listbox1.items.add ("AutoUpdate(VX2)")
IO.Directory.Delete(" C:\WINDOWS\System32\vwix32.exe") then listbox1.items.add ("AutoUpdate(VX2)")
IO.Directory.Delete(" C:\WINDOWS\System32\sysmonnt.exe") then listbox1.items.add ("AutoUpdate(VX2)")
IO.Directory.Delete(" C:\WINDOWS\System32\winhcek32.exe") then listbox1.items.add ("AutoUpdate(VX2)")
IO.Directory.Delete(" C:\WINDOWS\System32\qlykdnb.dll") then listbox1.items.add ("AutoUpdate(VX2)")
IO.Directory.Delete(" C:\WINDOWS\System32\rypgvtoimrl.exe") then listbox1.items.add ("AutoUpdate(VX2)")
IO.Directory.Delete(" C:\WINDOWS\System32\spwgoc.exe ") then listbox1.items.add ("AutoUpdate(VX2)")
IO.Directory.Delete(" C:\windows\system32\msnavc32.exe") then listbox1.items.add ("AutoUpdate(VX2)")
IO.Directory.Delete(" C:\WINDOWS\System32\sysmonnt") then listbox1.items.add ("AutoUpdate(VX2)")
IO.Directory.Delete(" C:\Program Files\hpdll\hpdll.exe ") then listbox1.items.add ("AutoUpdate(VX2)")
IO.Directory.Delete(" C:\WINDOWS\System32\w?wexec.exe") then listbox1.items.add ("AutoUpdate(VX2)")
IO.Directory.Delete(" C:\WINDOWS\isrvs\ffisearch.exe") then listbox1.items.add ("AutoUpdate(VX2)")
IO.Directory.Delete("c:\Program Files\Autosearch.dll") then listbox1.items.add ("AutoUpdate(VX2)")
IO.Directory.Delete("c:\Program Files\Browser Pal") then listbox1.items.add ("Adware.BrowserPal")

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Imports System.IO 
IO.Directory.Delete("c:\Program Files\ACM") then listbox2.items.add ("Spyware.ACM")
IO.Directory.Delete("c:\Program Files\Activity Keylogger") then listbox2.items.add ("Spyware.ActivityKey")
IO.Directory.Delete("c:\Program Files\Activity Logger") then listbox2.items.add ("Spyware.ActivityLog")
IO.Directory.Delete("c:\Program Files\Actual Spy") then listbox2.items.add ("Spyware.ActualSpy")
IO.Directory.Delete("c:\Program Files\AdvSearch") then listbox2.items.add ("Spyware.ActualNames")
IO.Directory.Delete("c:\Program Files\AppsTraka") then listbox2.items.add ("Spyware.AppsTraka")
IO.Directory.Delete("c:\Program Files\Ardamax Keylogger") then listbox2.items.add ("Spyware.Ardakey.B.")
IO.Directory.Delete("c:\Program Files\Auto Keylogger") then listbox2.items.add ("Spyware.IkitecKL")
IO.Directory.Delete("c:\Program Files\BazookaBar") then listbox2.items.add ("Spyware.Bazookabar")
IO.Directory.Delete("c:\Program Files\Blackbox7") then listbox2.items.add ("Spyware.Blackbox")
IO.Directory.Delete("c:\Program Files\Blackbox7") then listbox2.items.add ("")



End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Imports System.IO 
IO.Directory.Delete("c:\Program Files\aolx") then listbox3.items.add ("Backdoor W32.Allim.B")
IO.Directory.Delete("c:\Program Files\Archive.exe") then listbox3.items.add ("Trojan.Dloadr-ABP")
IO.Directory.Delete("c:\Program Files\Archive.exe") then listbox3.items.add ("Trojan.Cmapp")
IO.Directory.Delete("c:\Program Files\BTV") then listbox3.items.add ("Breg_inst.exe")
End Sub
Class
End Class


Error 1 End of statement expected. C:\Documents and Settings\Doggy\My Documents\Visual Studio 2008\Projects\BoneScrapper Anti-Virus Beta\BoneScrapper Anti-Virus Beta\BoneScrapper Antivirus Beta.vb 2 109 BoneScrapper Anti-Virus Beta

Error 2 End of statement expected. C:\Documents and Settings\Doggy\My Documents\Visual Studio 2008\Projects\BoneScrapper Anti-Virus Beta\BoneScrapper Anti-Virus Beta\BoneScrapper Antivirus Beta.vb 30 109 BoneScrapper Anti-Virus Beta

Error 3 End of statement expected. C:\Documents and Settings\Doggy\My Documents\Visual Studio 2008\Projects\BoneScrapper Anti-Virus Beta\BoneScrapper Anti-Virus Beta\BoneScrapper Antivirus Beta.vb 47 109 BoneScrapper Anti-Virus Beta

Error 4 Identifier expected. C:\Documents and Settings\Doggy\My Documents\Visual Studio 2008\Projects\BoneScrapper Anti-Virus Beta\BoneScrapper Anti-Virus Beta\BoneScrapper Antivirus Beta.vb 53 5 BoneScrapper Anti-Virus Beta


Please helppppppp,my scripting is worse:(
Was This Post Helpful? 0
  • +
  • -

#9 searockruz  Icon User is offline

  • D.I.C Regular

Reputation: 24
  • View blog
  • Posts: 460
  • Joined: 07-March 09

Re: Deliting files from a letterbox in VB2008

Posted 28 August 2009 - 04:14 AM

This is a wrong way of adding namespaces in your code

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Imports System.IO
IO.Directory.Delete("c:\Program Files\180 SearchAssistant") then listbox1.items.add ("Adware.180Search")




You need to add Imports System.IO above your class
Heres a example
Imports System.IO
Class IconExtractor
........
End Class


This post has been edited by searockruz: 28 August 2009 - 04:15 AM

Was This Post Helpful? 1

#10 PDUNZ  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 43
  • View blog
  • Posts: 376
  • Joined: 17-July 09

Re: Deliting files from a letterbox in VB2008

Posted 28 August 2009 - 06:26 AM

If you are using the buttons to delete - remove all of the then listbox1.items.add ("Adware.180Search") etc. You are getting an "End of statement expected" because you have a "Then" but no "IF". Also, you were using IO.Directory.Delete for files, so I changed those to IO.File.Delete.

Here's the updated code.
 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
		IO.Directory.Delete("c:\Program Files\180 SearchAssistant")
		IO.Directory.Delete("c:\Program Files\2Search")
		IO.Directory.Delete("c:\Program Files\5whgue21")
		IO.File.Delete("c:\Program Files\AdStatComm.dll")
		IO.File.Delete(" C:\Program Files\0er8k4va\0er8k4va.exe")
		IO.File.Delete(" C:\WINDOWS\System32\Mkfxut.exe")
		IO.File.Delete(" C:\WINDOWS\system32\pkdacs.exe")
		IO.File.Delete(" C:\WINDOWS\System32\ywrqku.exe")
		IO.File.Delete(" C:\windows\system32\msnavc32.exe")
		IO.File.Delete(" C:\Program Files\AutoUpdate\AutoUpdate.exe")
		IO.File.Delete(" C:\WINDOWS\System32\winntcreate.exe")
		IO.File.Delete(" C:\WINDOWS\System32\vwix32.exe")
		IO.File.Delete(" C:\WINDOWS\System32\sysmonnt.exe")
		IO.File.Delete(" C:\WINDOWS\System32\winhcek32.exe")
		IO.File.Delete(" C:\WINDOWS\System32\qlykdnb.dll")
		IO.File.Delete(" C:\WINDOWS\System32\rypgvtoimrl.exe")
		IO.File.Delete(" C:\WINDOWS\System32\spwgoc.exe ")
		IO.File.Delete(" C:\windows\system32\msnavc32.exe")
		IO.File.Delete(" C:\WINDOWS\System32\sysmonnt")
		IO.File.Delete(" C:\Program Files\hpdll\hpdll.exe ")
		IO.File.Delete(" C:\WINDOWS\System32\w?wexec.exe")
		IO.File.Delete(" C:\WINDOWS\isrvs\ffisearch.exe")
		IO.File.Delete("c:\Program Files\Autosearch.dll")
		IO.Directory.Delete("c:\Program Files\Browser Pal")

	End Sub

	Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
		IO.Directory.Delete("c:\Program Files\ACM")
		IO.Directory.Delete("c:\Program Files\Activity Keylogger")
		IO.Directory.Delete("c:\Program Files\Activity Logger")
		IO.Directory.Delete("c:\Program Files\Actual Spy")
		IO.Directory.Delete("c:\Program Files\AdvSearch")
		IO.Directory.Delete("c:\Program Files\AppsTraka")
		IO.Directory.Delete("c:\Program Files\Ardamax Keylogger")
		IO.Directory.Delete("c:\Program Files\Auto Keylogger")
		IO.Directory.Delete("c:\Program Files\BazookaBar")
		IO.Directory.Delete("c:\Program Files\Blackbox7")
		IO.Directory.Delete("c:\Program Files\Blackbox7")
	End Sub

	Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
		IO.Directory.Delete("c:\Program Files\aolx")
		IO.File.Delete("c:\Program Files\Archive.exe")
		IO.File.Delete("c:\Program Files\Archive.exe")
		IO.Directory.Delete("c:\Program Files\BTV")
	End Sub




But I would strongly suggest looking into using arrays/collections to cut down the amount of code needed (maybe 2 arrays and 5 lines of code to do the same as above).

This post has been edited by PDUNZ: 28 August 2009 - 07:19 AM

Was This Post Helpful? 0
  • +
  • -

#11 PDUNZ  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 43
  • View blog
  • Posts: 376
  • Joined: 17-July 09

Re: Deliting files from a letterbox in VB2008

Posted 28 August 2009 - 07:12 AM

Example of using arrays to acheive.

	' Array of Files.
	Dim Files() As String = {"File1", "File2"}
	
	Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
		' Loop through Files(), add to listbox1, and delete.
		For i = 0 To Files.GetUpperBound(0)
			If IO.File.Exists(i) Then
				Listbox1.Items.Add(i)
				IO.File.Delete(i)
			End If
		Next
	End Sub



This post has been edited by PDUNZ: 28 August 2009 - 07:35 AM

Was This Post Helpful? 0
  • +
  • -

#12 Roxor  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 3
  • View blog
  • Posts: 41
  • Joined: 27-August 09

Re: Deliting files from a letterbox in VB2008

Posted 29 August 2009 - 12:24 AM

The heck,i always get an "Statement is not valid in a namespace" at the buttons code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

P.S. The thing with the array of files is interesting,but a little bit complicated.I'm making efforts.But,please,can you paste the complete code with de files and directories i wanna delete(the incorrect code is upper).I want the array code just to paste in the AV and work.Please!I can't make it work alone.Please help with this errors and my noobidity.Thanx. ;)
Was This Post Helpful? 0
  • +
  • -

#13 Roxor  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 3
  • View blog
  • Posts: 41
  • Joined: 27-August 09

Re: Deliting files from a letterbox in VB2008

Posted 29 August 2009 - 12:33 AM

Okay,I tried to modify the array code,and no error!(hope it Workz:D)
Private If Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' Loop through Files(), add to listbox1, and delete.
	For i = 0 To Files.GetUpperBound(0)
		If IO.File.Exists(i) Then
			Listbox1.Items.Add(i)
			IO.File.Delete(i)
		End If
	Next
End Sub

And this should do the trick!
Please send me the complete code with all the folders and files to Del.Thnx! :^:
Was This Post Helpful? 0
  • +
  • -

#14 Roxor  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 3
  • View blog
  • Posts: 41
  • Joined: 27-August 09

Re: Deliting files from a letterbox in VB2008

Posted 29 August 2009 - 07:50 AM

Ohh,no.I can't get my code work.The arrays are'n what i want.I want something easyer!!!I want a code to scan lots of directories,delete them and show them on a listbox,and another to scan lots of files,delete them and show them on the same listbox.Please,help me,but provide me with usefull information.Is VB so hard????
So,don't forget WHAT I WANT!!! :
To scan some computer folders and files,if some folders and files matched exists,then the AV will delete then and it is very important to show them on a listbox.
1 HUGE PROBLEM: The button code always has an "Statement is not valid in a namespace",or "End of statement expect",i edited it as i can,and still has the problem.PLEASE LOOK AT IT:
 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click


Error 1 Statement is not valid in a namespace. C:\Documents and Settings\Doggy\My Documents\Visual Studio 2008\Projects\BoneScrapper Anti-Virus Beta\BoneScrapper Anti-Virus Beta\BoneScrapper Antivirus Beta.vb 2 1 BoneScrapper Anti-Virus Beta


[code]Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Imports System.IO [code]
Error 2 End of statement expected. C:\Documents and Settings\Doggy\My Documents\Visual Studio 2008\Projects\BoneScrapper Anti-Virus Beta\BoneScrapper Anti-Virus Beta\BoneScrapper Antivirus Beta.vb 30 109 BoneScrapper Anti-Virus Beta


As i said,i'm fresh at Visual Basic,so i implore someone to help me,and give me the correct code,cause i'm very sad :huh: :/ :exc2l:
Was This Post Helpful? 0
  • +
  • -

#15 PDUNZ  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 43
  • View blog
  • Posts: 376
  • Joined: 17-July 09

Re: Deliting files from a letterbox in VB2008

Posted 29 August 2009 - 08:18 AM

Thats exactly what my code i showed above does - it goes through and if it finds a match it adds it to the listbox and deletes the file/directory, although I had an error in there (it was looking for a number, not the file).

Here's the whole code, its a working version - I have tested it.

The arrays, add below public class form1
   ' Array of Files.
	Dim Files() As String = {"c:\Program Files\AdStatComm.dll", "C:\Program Files\0er8k4va\0er8k4va.exe", "C:\WINDOWS\System32\Mkfxut.exe", "C:\WINDOWS\system32\pkdacs.exe", _
							 "C:\WINDOWS\System32\ywrqku.exe", "C:\windows\system32\msnavc32.exe", "C:\Program Files\AutoUpdate\AutoUpdate.exe", "C:\WINDOWS\System32\vwix32.exe", _
							 "C:\WINDOWS\System32\winntcreate.exe", "C:\WINDOWS\System32\sysmonnt.exe", "C:\WINDOWS\System32\winhcek32.exe", "C:\WINDOWS\System32\qlykdnb.dll", _
							 "C:\WINDOWS\System32\rypgvtoimrl.exe", "C:\WINDOWS\System32\spwgoc.exe", "C:\windows\system32\msnavc32.exe", "C:\WINDOWS\System32\sysmonnt", _
							 "C:\Program Files\hpdll\hpdll.exe", "C:\WINDOWS\System32\w?wexec.exe", "C:\WINDOWS\isrvs\ffisearch.exe", "c:\Program Files\Autosearch.dll", _
							 "c:\Program Files\Archive.exe", "c:\Program Files\Archive.exe"}
	' Array of Directories.
	Dim Dirs() As String = {"c:\Program Files\180 SearchAssistant", "c:\Program Files\2Search", "c:\Program Files\5whgue21", "c:\Program Files\aolx", "c:\Program Files\ACM", _
							"c:\Program Files\Browser Pal", "c:\Program Files\Activity Keylogger", "c:\Program Files\Activity Logger", "c:\Program Files\Actual Spy", _
							"c:\Program Files\AdvSearch", "c:\Program Files\AppsTraka", "c:\Program Files\Ardamax Keylogger", "c:\Program Files\Auto Keylogger", _
							"c:\Program Files\BazookaBar", "c:\Program Files\Blackbox7", "c:\Program Files\Blackbox7", "c:\Program Files\BTV"}




Code to scan files, add to listbox if found, and also delete.
   ' Loop through Files(), add any found to listbox, and delete.
		For i = 0 To Files.GetUpperBound(0)
			If IO.File.Exists(Files(i)) Then
				ListBox1.Items.Add(Files(i))
				IO.File.Delete(Files(i))
			End If
		Next




Code to scan directories, add to listbox if found, and also delete.
  ' Loop through Dirs(), add any found to listbox, and delete.
		For i = 0 To Dirs.GetUpperBound(0)
			If IO.Directory.Exists(Dirs(i)) Then
				ListBox2.Items.Add(Dirs(i))
				IO.Directory.Delete(Dirs(i))
			End If
		Next



I cant see anything wrong with your button code except for button2 - delete
Imports System.IO and add it above public class form1 (the very first line).

This post has been edited by PDUNZ: 29 August 2009 - 08:43 AM

Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2