473,698 Members | 2,594 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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:\Documen ts and
Settings\divitd c\My Documents"

Dim myDirectory As DirectoryInfo
myDirectory = New DirectoryInfo(n ameOfDirectory)
MainClass.AllTe xt = MainClass.AllTe xt &
My.Computer.Fil eSystem.GetFile s(nameOfDirecto ry).Count & vbCrLf
MainClass.Label 1.Text = nameOfDirectory
MainClass.Label 1.Visible = True
WorkWithDirecto ry(myDirectory)
MainClass.Label 1.Visible = False
End Sub

Public Shared Sub WorkWithDirecto ry(ByVal aDir As DirectoryInfo)
Dim nextDir As DirectoryInfo
MainClass.Label 1.Text = aDir.FullName.T oString
WorkWithFilesIn Dir(aDir)
For Each nextDir In aDir.GetDirecto ries
MainClass.Label 1.Text = nextDir.FullNam e.ToString
WorkWithDirecto ry(nextDir)
Next
End Sub

Public Shared Sub WorkWithFilesIn Dir(ByVal aDir As DirectoryInfo)
Dim aFile As FileInfo
For Each aFile In aDir.GetFiles()
MainClass.AllTe xt = MainClass.AllTe xt & aFile.FullName &
vbCrLf
MainClass.RichT extBox1.Text = MainClass.AllTe xt
Next

End Sub
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e
As System.EventArg s) 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 1877
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*****@dystop ic.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:\Documen ts and
Settings\divit dc\My Documents"

Dim myDirectory As DirectoryInfo
myDirectory = New DirectoryInfo(n ameOfDirectory)
MainClass.AllTe xt = MainClass.AllTe xt &
My.Computer.Fi leSystem.GetFil es(nameOfDirect ory).Count & vbCrLf
MainClass.Label 1.Text = nameOfDirectory
MainClass.Label 1.Visible = True
WorkWithDirecto ry(myDirectory)
MainClass.Label 1.Visible = False
End Sub

Public Shared Sub WorkWithDirecto ry(ByVal aDir As DirectoryInfo)
Dim nextDir As DirectoryInfo
MainClass.Label 1.Text = aDir.FullName.T oString
WorkWithFilesIn Dir(aDir)
For Each nextDir In aDir.GetDirecto ries
MainClass.Label 1.Text = nextDir.FullNam e.ToString
WorkWithDirecto ry(nextDir)
Next
End Sub

Public Shared Sub WorkWithFilesIn Dir(ByVal aDir As DirectoryInfo)
Dim aFile As FileInfo
For Each aFile In aDir.GetFiles()
MainClass.AllTe xt = MainClass.AllTe xt & aFile.FullName &
vbCrLf
MainClass.RichT extBox1.Text = MainClass.AllTe xt
Next

End Sub
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e
As System.EventArg s) 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 BackgroundWorke r Thread.
This control may simplify a lot of threading questions for you.
"Daniel C. Di Vita" <dd*****@dystop ic.comwrote in message
news:7l******** *************** *********@4ax.c om...
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*****@dystop ic.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:\Documen ts and
Settings\divi tdc\My Documents"

Dim myDirectory As DirectoryInfo
myDirectory = New DirectoryInfo(n ameOfDirectory)
MainClass.AllTe xt = MainClass.AllTe xt &
My.Computer.F ileSystem.GetFi les(nameOfDirec tory).Count & vbCrLf
MainClass.Label 1.Text = nameOfDirectory
MainClass.Label 1.Visible = True
WorkWithDirecto ry(myDirectory)
MainClass.Label 1.Visible = False
End Sub

Public Shared Sub WorkWithDirecto ry(ByVal aDir As DirectoryInfo)
Dim nextDir As DirectoryInfo
MainClass.Label 1.Text = aDir.FullName.T oString
WorkWithFilesIn Dir(aDir)
For Each nextDir In aDir.GetDirecto ries
MainClass.Label 1.Text = nextDir.FullNam e.ToString
WorkWithDirecto ry(nextDir)
Next
End Sub

Public Shared Sub WorkWithFilesIn Dir(ByVal aDir As DirectoryInfo)
Dim aFile As FileInfo
For Each aFile In aDir.GetFiles()
MainClass.AllTe xt = MainClass.AllTe xt & aFile.FullName &
vbCrLf
MainClass.RichT extBox1.Text = MainClass.AllTe xt
Next

End Sub
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e
As System.EventArg s) 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 BackgroundWorke r Thread.
This control may simplify a lot of threading questions for you.
"Daniel C. Di Vita" <dd*****@dystop ic.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*****@dysto pic.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:\Documen ts and
Settings\div itdc\My Documents"

Dim myDirectory As DirectoryInfo
myDirectory = New DirectoryInfo(n ameOfDirectory)
MainClass.AllTe xt = MainClass.AllTe xt &
My.Computer. FileSystem.GetF iles(nameOfDire ctory).Count & vbCrLf
MainClass.Label 1.Text = nameOfDirectory
MainClass.Label 1.Visible = True
WorkWithDirecto ry(myDirectory)
MainClass.Label 1.Visible = False
End Sub

Public Shared Sub WorkWithDirecto ry(ByVal aDir As DirectoryInfo)
Dim nextDir As DirectoryInfo
MainClass.Label 1.Text = aDir.FullName.T oString
WorkWithFilesIn Dir(aDir)
For Each nextDir In aDir.GetDirecto ries
MainClass.Label 1.Text = nextDir.FullNam e.ToString
WorkWithDirecto ry(nextDir)
Next
End Sub

Public Shared Sub WorkWithFilesIn Dir(ByVal aDir As DirectoryInfo)
Dim aFile As FileInfo
For Each aFile In aDir.GetFiles()
MainClass.AllTe xt = MainClass.AllTe xt & aFile.FullName &
vbCrLf
MainClass.RichT extBox1.Text = MainClass.AllTe xt
Next

End Sub
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e
As System.EventArg s) 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
2519
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 that I had to turn the directory listing into an array and then use "foreach (array as item)" to go through and open each file but I've tried several different approaches and I just can't get it to work. I've been able to make it list the directory...
5
20103
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
3666
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 compiler? Or this is too os dependent, system-specific functions must be called? I think about this when i tried to do this under windows, i found in order to achieve this, some windows-specific api such as FindFirstFile, FindNextFile must be...
4
3706
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 Directory.GetFileSystemEntries(path), but I would like to know how to put this together, knowing which entry is a Subdirectory and which entry is a file, and make a recursive list of the Directory structure below a specific path - - -
8
11061
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) index.html site/pagefile/
3
5669
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 progstatus. Does anyone know how to set this up with the code below? appreciate it. thank you. Private Function Dir(ByVal sDir As String)
4
3248
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 variable set to this: --- $dir = getcwd() . "\\" . $nav; --- but for some reason the script does not actually display the contents of the directory if you change from the directory the script is located in. Here is my code if someone is willing...
2
2397
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. I dropped some code in to echo out the name of the file that's about to be rmdir()ed or unoink()ed (depending if it's a file or a directory) to see if it was choking on a particular subdirectory, but doing that causes all the error messages to...
5
4194
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 directory that I want to delete. Basically, the loop is working great also the bgworker has no problem I remove the update progress function. The error is exceeding the value of progressbar. Is there anyway to update the progressbar on the fly of...
0
8678
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
8899
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8871
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7737
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6525
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5861
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4371
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.