K
Kyote
I'm trying to make, what I thought, would be a simple application.
This application will help me organize files I have a lot of, on my
computer(ebooks, pictures, etc..). I'm currently dealing with over
25,000 files in a couple hundred directories.
I'm currently trying to collect the list using this
Try
For Each foundfile As String In
My.Computer.FileSystem.GetFiles(mySource,
FileIO.SearchOption.SearchAllSubDirectories, "*.*")
Application.DoEvents()
listOfFiles.Add(foundfile)
Next
Catch ex As System.UnauthorizedAccessException
MessageBox.Show(ex.Message & vbNewLine & "Please choose another
source folder")
End Try
But with only the 25,000 files I currently have, I get the clr warning
message. I put the Application.DoEvents() in hoping to solve the
problem but it doesn't. So I stepped through the code and it is
hanging on the for each line.
I've been googling around and I think I can probably solve my problem
by using a backgroundworker. But after reading some on the use of it
I'm simply lost. Heck, I'm not even sure I need to use the
backgroundworker to solve the problem. But from what I've read it
should be able to solve the problem I'm having.
If there's simple way to do what I need could someone tell me about
it?
But also, could someone please give a full, short example, for a
novice to vb.net, to using a backgroundworker to list all files using
for each basing the example on my code above? Something I can plug
into a new app and step through to gain some understanding of the
backgroundworkers usage? From what I've read it seems like it could be
very very useful to know how to use it.
This application will help me organize files I have a lot of, on my
computer(ebooks, pictures, etc..). I'm currently dealing with over
25,000 files in a couple hundred directories.
I'm currently trying to collect the list using this
Try
For Each foundfile As String In
My.Computer.FileSystem.GetFiles(mySource,
FileIO.SearchOption.SearchAllSubDirectories, "*.*")
Application.DoEvents()
listOfFiles.Add(foundfile)
Next
Catch ex As System.UnauthorizedAccessException
MessageBox.Show(ex.Message & vbNewLine & "Please choose another
source folder")
End Try
But with only the 25,000 files I currently have, I get the clr warning
message. I put the Application.DoEvents() in hoping to solve the
problem but it doesn't. So I stepped through the code and it is
hanging on the for each line.
I've been googling around and I think I can probably solve my problem
by using a backgroundworker. But after reading some on the use of it
I'm simply lost. Heck, I'm not even sure I need to use the
backgroundworker to solve the problem. But from what I've read it
should be able to solve the problem I'm having.
If there's simple way to do what I need could someone tell me about
it?
But also, could someone please give a full, short example, for a
novice to vb.net, to using a backgroundworker to list all files using
for each basing the example on my code above? Something I can plug
into a new app and step through to gain some understanding of the
backgroundworkers usage? From what I've read it seems like it could be
very very useful to know how to use it.