[Help] Debugging Errors

Posts 111 of 11 · Page 1 of 1
[Help] Debugging Errors


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.Text.Contains("") 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.Text.Contains("") 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.Text.Contains("") 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)
Post code.

We can't help you fix the error without seeing the code.
mscorlib.dll is trojan -.-
Quote Originally Posted by /b/oss View Post
mscorlib.dll is trojan -.-
I really hate to disrespect a minion, but that's a ridiculously stupid comment.

One sec, I'll edit first post and add source code.
Quote Originally Posted by /b/oss View Post
mscorlib.dll is trojan -.-
Quote Originally Posted by m_t_h
try import system.io?

about your compliment: well, just tell you that's trojan -.- instead of saying thanks you did that
Quote Originally Posted by ~Jay~
a lot of people do that compared to the thanks people derserve
Facewall !!

@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 Sub
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
When 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.

Hope this helps ^_~
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
Quote Originally Posted by /b/oss View Post
try import system.io?

about your compliment: well, just tell you that's trojan -.- instead of saying thanks you did that
a lot of people do that compared to the thanks people derserve
Quote Originally Posted by /b/oss View Post
try import system.io?

about your compliment: well, just tell you that's trojan -.- instead of saying thanks you did that
Urm... I'm not necessarily trying to... Make you look... Uh...

Nevermind... It isn't a trojan though... ;/

I like you M_T_H.. But I think you should google it next time :/


As for the resonses, I believe it as because of a missing .dll from dotn*tB*r xP
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.

try import system.io?

about your compliment: well, just tell you that's trojan -.- instead of saying thanks you did that
/facewall a lot

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
Posts 111 of 11 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Need help?