|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Recursive Directory / File Listing With Progress?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 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 <ddiv***@dystopic.com> wrote: Show quoteHide quote >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 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. Show quoteHide quote "Daniel C. Di Vita" <ddiv***@dystopic.com> wrote in message news:7li2i29ukvp81ssr7do3ngakbms55o1sq7@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 > <ddiv***@dystopic.com> wrote: > >>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 I did find that, but thanks for your reply.
Daniel Show quoteHide quote On Tue, 3 Oct 2006 14:00:56 -0500, "AMDRIT" <amd***@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" <ddiv***@dystopic.com> wrote in message >news:7li2i29ukvp81ssr7do3ngakbms55o1sq7@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 >> <ddiv***@dystopic.com> wrote: >> >>>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 >
Q: closing forms
CURRENT INDEX of Iteration on ILIST collection ? 1.1 equivalent for Drawing.Icon.ExtractAssociatedIcon? Accessing the Class Name of a Shared Method Writing Custom DLLs in VB.net 2 Help with using bits in an integer new form use try catch to check a text box copy and paste into webbrowser Set Statement vs Function |
|||||||||||||||||||||||