473,387 Members | 1,669 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Recursive Directory / File Listing With Progress?

I am stating to write a small app that allows a user to catalog their
CD/dvd collection. I need some help, however. Here is some test code I
wrote for the recursive listing:

Imports System
Imports System.IO

Public Class MainClass
Dim AllText As String = ""
Shared Sub Main()
Dim nameOfDirectory As String = "C:\Documents and
Settings\divitdc\My Documents"

Dim myDirectory As DirectoryInfo
myDirectory = New DirectoryInfo(nameOfDirectory)
MainClass.AllText = MainClass.AllText &
My.Computer.FileSystem.GetFiles(nameOfDirectory).C ount & vbCrLf
MainClass.Label1.Text = nameOfDirectory
MainClass.Label1.Visible = True
WorkWithDirectory(myDirectory)
MainClass.Label1.Visible = False
End Sub

Public Shared Sub WorkWithDirectory(ByVal aDir As DirectoryInfo)
Dim nextDir As DirectoryInfo
MainClass.Label1.Text = aDir.FullName.ToString
WorkWithFilesInDir(aDir)
For Each nextDir In aDir.GetDirectories
MainClass.Label1.Text = nextDir.FullName.ToString
WorkWithDirectory(nextDir)
Next
End Sub

Public Shared Sub WorkWithFilesInDir(ByVal aDir As DirectoryInfo)
Dim aFile As FileInfo
For Each aFile In aDir.GetFiles()
MainClass.AllText = MainClass.AllText & aFile.FullName &
vbCrLf
MainClass.RichTextBox1.Text = MainClass.AllText
Next

End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click

Main()

End Sub

End Class
So you click a button and it fills the textbox with the folders and
files.

My label never becomes visible or updates until the process is
finished. Why? How can I make it update in real-time?

Also if there are a lot of folders/ files the app tends to hang if I
try to click on it. It will run as long as I don't touch it.

How can I created a selection of just CD/DVD drives?

Any ideas on how to make this code more stable would be great. Thank
you.

Daniel

Oct 2 '06 #1
3 1863
Ok, I found that using the .update command for the label and
richtextbox works great.

On Mon, 02 Oct 2006 13:07:44 -0400, Daniel C. Di Vita
<dd*****@dystopic.comwrote:
>I am stating to write a small app that allows a user to catalog their
CD/dvd collection. I need some help, however. Here is some test code I
wrote for the recursive listing:

Imports System
Imports System.IO

Public Class MainClass
Dim AllText As String = ""
Shared Sub Main()
Dim nameOfDirectory As String = "C:\Documents and
Settings\divitdc\My Documents"

Dim myDirectory As DirectoryInfo
myDirectory = New DirectoryInfo(nameOfDirectory)
MainClass.AllText = MainClass.AllText &
My.Computer.FileSystem.GetFiles(nameOfDirectory). Count & vbCrLf
MainClass.Label1.Text = nameOfDirectory
MainClass.Label1.Visible = True
WorkWithDirectory(myDirectory)
MainClass.Label1.Visible = False
End Sub

Public Shared Sub WorkWithDirectory(ByVal aDir As DirectoryInfo)
Dim nextDir As DirectoryInfo
MainClass.Label1.Text = aDir.FullName.ToString
WorkWithFilesInDir(aDir)
For Each nextDir In aDir.GetDirectories
MainClass.Label1.Text = nextDir.FullName.ToString
WorkWithDirectory(nextDir)
Next
End Sub

Public Shared Sub WorkWithFilesInDir(ByVal aDir As DirectoryInfo)
Dim aFile As FileInfo
For Each aFile In aDir.GetFiles()
MainClass.AllText = MainClass.AllText & aFile.FullName &
vbCrLf
MainClass.RichTextBox1.Text = MainClass.AllText
Next

End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click

Main()

End Sub

End Class
So you click a button and it fills the textbox with the folders and
files.

My label never becomes visible or updates until the process is
finished. Why? How can I make it update in real-time?

Also if there are a lot of folders/ files the app tends to hang if I
try to click on it. It will run as long as I don't touch it.

How can I created a selection of just CD/DVD drives?

Any ideas on how to make this code more stable would be great. Thank
you.

Daniel
Oct 2 '06 #2
If you are using 2.0 Framework, take a look at the BackgroundWorker Thread.
This control may simplify a lot of threading questions for you.
"Daniel C. Di Vita" <dd*****@dystopic.comwrote in message
news:7l********************************@4ax.com...
Ok, I found that using the .update command for the label and
richtextbox works great.

On Mon, 02 Oct 2006 13:07:44 -0400, Daniel C. Di Vita
<dd*****@dystopic.comwrote:
>>I am stating to write a small app that allows a user to catalog their
CD/dvd collection. I need some help, however. Here is some test code I
wrote for the recursive listing:

Imports System
Imports System.IO

Public Class MainClass
Dim AllText As String = ""
Shared Sub Main()
Dim nameOfDirectory As String = "C:\Documents and
Settings\divitdc\My Documents"

Dim myDirectory As DirectoryInfo
myDirectory = New DirectoryInfo(nameOfDirectory)
MainClass.AllText = MainClass.AllText &
My.Computer.FileSystem.GetFiles(nameOfDirectory) .Count & vbCrLf
MainClass.Label1.Text = nameOfDirectory
MainClass.Label1.Visible = True
WorkWithDirectory(myDirectory)
MainClass.Label1.Visible = False
End Sub

Public Shared Sub WorkWithDirectory(ByVal aDir As DirectoryInfo)
Dim nextDir As DirectoryInfo
MainClass.Label1.Text = aDir.FullName.ToString
WorkWithFilesInDir(aDir)
For Each nextDir In aDir.GetDirectories
MainClass.Label1.Text = nextDir.FullName.ToString
WorkWithDirectory(nextDir)
Next
End Sub

Public Shared Sub WorkWithFilesInDir(ByVal aDir As DirectoryInfo)
Dim aFile As FileInfo
For Each aFile In aDir.GetFiles()
MainClass.AllText = MainClass.AllText & aFile.FullName &
vbCrLf
MainClass.RichTextBox1.Text = MainClass.AllText
Next

End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click

Main()

End Sub

End Class
So you click a button and it fills the textbox with the folders and
files.

My label never becomes visible or updates until the process is
finished. Why? How can I make it update in real-time?

Also if there are a lot of folders/ files the app tends to hang if I
try to click on it. It will run as long as I don't touch it.

How can I created a selection of just CD/DVD drives?

Any ideas on how to make this code more stable would be great. Thank
you.

Daniel

Oct 3 '06 #3
I did find that, but thanks for your reply.

Daniel
On Tue, 3 Oct 2006 14:00:56 -0500, "AMDRIT" <am****@hotmail.com>
wrote:
>If you are using 2.0 Framework, take a look at the BackgroundWorker Thread.
This control may simplify a lot of threading questions for you.
"Daniel C. Di Vita" <dd*****@dystopic.comwrote in message
news:7l********************************@4ax.com.. .
>Ok, I found that using the .update command for the label and
richtextbox works great.

On Mon, 02 Oct 2006 13:07:44 -0400, Daniel C. Di Vita
<dd*****@dystopic.comwrote:
>>>I am stating to write a small app that allows a user to catalog their
CD/dvd collection. I need some help, however. Here is some test code I
wrote for the recursive listing:

Imports System
Imports System.IO

Public Class MainClass
Dim AllText As String = ""
Shared Sub Main()
Dim nameOfDirectory As String = "C:\Documents and
Settings\divitdc\My Documents"

Dim myDirectory As DirectoryInfo
myDirectory = New DirectoryInfo(nameOfDirectory)
MainClass.AllText = MainClass.AllText &
My.Computer.FileSystem.GetFiles(nameOfDirectory ).Count & vbCrLf
MainClass.Label1.Text = nameOfDirectory
MainClass.Label1.Visible = True
WorkWithDirectory(myDirectory)
MainClass.Label1.Visible = False
End Sub

Public Shared Sub WorkWithDirectory(ByVal aDir As DirectoryInfo)
Dim nextDir As DirectoryInfo
MainClass.Label1.Text = aDir.FullName.ToString
WorkWithFilesInDir(aDir)
For Each nextDir In aDir.GetDirectories
MainClass.Label1.Text = nextDir.FullName.ToString
WorkWithDirectory(nextDir)
Next
End Sub

Public Shared Sub WorkWithFilesInDir(ByVal aDir As DirectoryInfo)
Dim aFile As FileInfo
For Each aFile In aDir.GetFiles()
MainClass.AllText = MainClass.AllText & aFile.FullName &
vbCrLf
MainClass.RichTextBox1.Text = MainClass.AllText
Next

End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click

Main()

End Sub

End Class
So you click a button and it fills the textbox with the folders and
files.

My label never becomes visible or updates until the process is
finished. Why? How can I make it update in real-time?

Also if there are a lot of folders/ files the app tends to hang if I
try to click on it. It will run as long as I don't touch it.

How can I created a selection of just CD/DVD drives?

Any ideas on how to make this code more stable would be great. Thank
you.

Daniel
Oct 3 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: Kim Jensen | last post by:
I'd like to make a directory listing where instead of the entire filename I need it to show the filename minus the extention and get the value of charname= in the file itself. I've been told...
5
by: betterdie | last post by:
Dear guru I want to delete all file and folder recursivly under php code, can anyone give me commend for this. Thank very much
10
by: ibic | last post by:
Just curious: is it possible to recursively list all the directorys/files inside a given directory using standard c i/o library routines only, which can be re-compiled and run on any os supportes c...
4
by: Elmo Watson | last post by:
Is there a way, with the System.IO class, to do a recursive list of a directory structure? For instance, in DirectoryInfo, you have GetDirectories and GetFiles .... In Directory, you have...
8
by: gil | last post by:
Is it possible to prevent a browser from listing the entire contents of a folder? The site, is hosted on my ISP with the following layout- site/ "user name from ISP" pagefile (dir)...
3
by: Gabe Matteson | last post by:
I am trying to set the maximum value of the progress bar so that when a user searches through the specified directory they can see their status. the progress bar name is on form2 and is named...
4
by: techusky | last post by:
I have a *very* simple script written that displays the directory listing of the current working directory, but I am having some difficulty when I try to change folders. Basically, I have my $dir...
2
by: Gordon | last post by:
I'm trying to remove a directory and all its contents from within a script. I wrote a recursive function to take care of it, but when I run it I get random "Directory not empty" error messages. ...
5
by: kyawsithu | last post by:
Hi, I am new to windows application. Can anyone give me the answer on my issue? The issue is updating the progressbar of bgworker from recursive loop. The recursive loop is using to find the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.