Post code.
We can't help you fix the error without seeing the code.
Not sure what the cause of this is. Let me know if there are any ideas to solve the issue.
Should I ignore it? Or... What? Dx
Also, the application crashes on other pc's :/
[php]Public Class Form1
Public Function searchDir(ByVal path As String) As List(Of String)
Dim paths As New Stack(Of String)
Dim files As New List(Of String)
paths.Push(path)
While paths.Count > 0
Dim dir As String = paths.Pop
Try
files.AddRange(IO.Directory.GetFiles(dir))
Catch ex As Exception
End Try
Try
For Each s As String In IO.Directory.GetDirectories(dir)
paths.Push(s)
Next
Catch ex As Exception
End Try
End While
Return files
End Function
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If ListBox1.Tex*****ntains("") Then
ButtonX2.Enabled = False
End If
End Sub
Private Sub ButtonX1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonX1.Click
For Each file As String In searchDir(ComboBox1.Text + ":/Windows/Prefetch")
ListBox1.Items.Add(file)
Next
If ListBox1.Tex*****ntains("") Then
Label1.Text = ("Select the drive that Windows is installed on")
End If
Label1.Text = ("Gathered prefetch folder contents. Please click 'Clear Prefetch' to finish.")
If ListBox1.Tex*****ntains("") Then
MsgBox("Either Windows is not installed on the selected drive" & vbNewLine & "or the prefetch folder is already cleared.")
End If
End Sub
Private Sub ButtonX2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonX2.Click
For Each f As String In searchDir(ComboBox1.Text + ":/Windows/Prefetch")
IO.File.Delete(f)
ListBox1.Items.Clear()
Next
Label1.Text = ("Finished cleaning prefetch folder")
End Sub
Private Sub LinkLabel1_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs ) Handles LinkLabel1.LinkClicked
Process.Start("")
End Sub
Private Sub LinkLabel1_LinkClicked_1(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs ) Handles LinkLabel1.LinkClicked
Process.Start("")
End Sub
End Class
[/php]
Some of the blank ""s are where text would be(removed due to advertising rule)
Last edited by Alroundeath; 07-28-2010 at 07:43 AM.
Post code.
We can't help you fix the error without seeing the code.
mscorlib.dll is trojan -.-
Well the error is saying that there might not be files in the selected folder, so you need to check if there are files in the folder before doing any file operations.
try import system.io?
about your compliment: well, just tell you that's trojan -.- instead of saying thanks you did that
Originally Posted by m_t_hFacewall !!Originally Posted by ~Jay~
@Problem:
I see the problem during the buttonX1 and buttonX2's search. The error occurs only when the user selects the drive other than that on which system is installed. You can access the environment variables and get where the windows is installed. Also you are doing 1 more mistake. You are using invalid path seperator ("/") while it should be ("\"). The / is used for network paths, not for local paths. I've changed and fixed the code for you.
This is the method for getting windows directory:
Code:Dim winDir As String=Environment.GetEnvironmentVariable("windir", EnvironmentVariableTarget.Machine)Code:Private Sub ButtonX1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonX1.Click Dim winDir As String=Environment.GetEnvironmentVariable("windir", EnvironmentVariableTarget.Machine) For Each file As String In searchDir(n & "\Prefetch") ListBox1.Items.Add(file) Next End SubWhen you can access the win directory, there's no need to ask user for where windows is installed. Just remove the comboBox and use the methods I just modified. That's the most effective way of doing this.Code:Private Sub ButtonX2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonX2.Click Dim winDir As String=Environment.GetEnvironmentVariable("windir", EnvironmentVariableTarget.Machine) For Each f As String In searchDir(n & "\Prefetch") IO.File.Delete(f) ListBox1.Items.Clear() Next Label1.Text = ("Finished cleaning prefetch folder") End Sub
Hope this helps ^_~
Last edited by Hassan; 07-28-2010 at 11:46 AM.
mscorlib.dll isn't a trojan.
[php]dim folder as string = "C:\Windows\Whatever"
If io.directory.exists(folder) then
for each file as string in searchdirectory(folder)
listbox1.items.add(file)
next
end if[/php]
The for-each-loop will only be executed if the folder exists -> Prevents application from stop working.
/facewall a lottry import system.io?
about your compliment: well, just tell you that's trojan -.- instead of saying thanks you did that
If he'd miss importing system.io, he couldn't even debug at all.
You can either:
Use io.directory.createdirectory / io.file.delete / io.file.exists
WITHOUT IMPORTING SYSTEM.IO
OR
Use directory.createdirectory / file.delete / file.exists
WITH IMPORTING SYSTEM.IO.
So I see, you either didn't read his question at all or you don't know how to import