|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Display the contents of a folder in a listbox?I have developed several databases in Access. I know VBA. I am making the
jump to VB and am currently using Visual basic 2005 Express. Can anyone give me a snippet that will show me how to list the contents of a directory in a listbox. If you could also point me toward a good beginners VB 2005 book or website I would appreciate it. Regards, Paul hi,
i'm using VS2003 as VS2005 is still in beta stage. but you can use this code in both version. first you need to import this name space : Imports System.IO than you can paste this code in a procedure or in Load event of the form : Dim filInfo As FileInfo For Each fil As String In Directory.GetFiles("d:\temp") filInfo = New FileInfo(fil) ListBox1.Items.Add(filInfo.Name) Next Dim DirInfo As DirectoryInfo For Each dir As String In Directory.GetDirectories("d:\temp") DirInfo = New DirectoryInfo(dir) ListBox1.Items.Add("[DIR] " & DirInfo.Name) Next this will fetch info from the Directory and fill the ListBox. and the site for the ebook. you can try this one: http://www.ingenieriauai.com.ar/eBooks/ PW: 01007011 i hope this will help you. VS 2005 has been out of beta and available to the public for a couple months
now. Show quoteHide quote "Lucky" <tushar.n.pa***@gmail.com> wrote in message news:1137410648.601897.133930@g43g2000cwa.googlegroups.com... > hi, > i'm using VS2003 as VS2005 is still in beta stage. but you can use > this code in both version. Dear Lucky:
This is IGFET909. You mentioned an ebook from http://www.ingenieriauai.com/ar/eBooks/ for access by Paul H. Would you happen to know whether there is an ebook for Microsoft Visual Basic 2005 Express? Thanks. ******* D.R.Steele Show quoteHide quote "Lucky" wrote: > hi, > i'm using VS2003 as VS2005 is still in beta stage. but you can use > this code in both version. > > first you need to import this name space : > > Imports System.IO > > than you can paste this code in a procedure or in Load event of the > form : > > Dim filInfo As FileInfo > For Each fil As String In Directory.GetFiles("d:\temp") > filInfo = New FileInfo(fil) > > ListBox1.Items.Add(filInfo.Name) > Next > > Dim DirInfo As DirectoryInfo > For Each dir As String In Directory.GetDirectories("d:\temp") > DirInfo = New DirectoryInfo(dir) > ListBox1.Items.Add("[DIR] " & DirInfo.Name) > Next > > this will fetch info from the Directory and fill the ListBox. > > and the site for the ebook. you can try this one: > > http://www.ingenieriauai.com.ar/eBooks/ > PW: 01007011 > > i hope this will help you. > > Hi,
Another book link http://www.vb-tips.com/default.aspx?ID=1b31f4f7-0596-4b8e-aaf5-e16db864a414 Ken ------------- Show quoteHide quote "Paul H" <nospam@nospam.com> wrote in message news:N9Lyf.92913$7p5.59961@newsfe4-win.ntli.net... >I have developed several databases in Access. I know VBA. I am making the >jump to VB and am currently using Visual basic 2005 Express. > > Can anyone give me a snippet that will show me how to list the contents of > a directory in a listbox. > > If you could also point me toward a good beginners VB 2005 book or website > I would appreciate it. > > Regards, > > Paul > "Paul H" <nospam@nospam.com> schrieb: \\\>I have developed several databases in Access. I know VBA. I am making the >jump to VB and am currently using Visual basic 2005 Express. > > Can anyone give me a snippet that will show me how to list the contents of > a directory in a listbox. Imports System.IO .... For Each FileName As String In Directory.GetFiles(...) Me.ListBox1.Items.Add(Path.GetFileName(FileName)) Next FileName /// -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/> "Paul H" <nospam@nospam.com> wrote in message I'm still playing with this but:news:N9Lyf.92913$7p5.59961@newsfe4-win.ntli.net... >I have developed several databases in Access. I know VBA. I am making the >jump to VB and am currently using Visual basic 2005 Express. > > Can anyone give me a snippet that will show me how to list the contents of > a directory in a listbox. > > If you could also point me toward a good beginners VB 2005 book or website > I would appreciate it. Dim S As String, I As Integer, L As ListViewItem, J As Long, T As Date For I = 0 To CheckedListBox1.Items.Count - 1 S = CheckedListBox1.Items(I) dlgOpenFile.InitialDirectory = S For Each foundFile As String In My.Computer.FileSystem.GetFiles( _ S, FileIO.SearchOption.SearchAllSubDirectories, "*.*") ListView2.Items.Add(foundFile) L = ListView2.Items(ListView2.Items.Count - 1) L.Checked = True Next I'm using a ListView but a Listbox works too. Ok doing something like this to fill a listview. The first time the following
line of code runs it takes like 15-20 seconds. If I open the form again it takes about 5 seconds. If I stop the app and wait 15 minutes or so and start the app in debug again the delay is there, but if start the app in debug immediatly after stopping a debug session there is no delay. Dim files() As System.IO.FileInfo = dirInfo.GetFiles("*.nc") Show quoteHide quote "Homer J Simpson" wrote: > > "Paul H" <nospam@nospam.com> wrote in message > news:N9Lyf.92913$7p5.59961@newsfe4-win.ntli.net... > >I have developed several databases in Access. I know VBA. I am making the > >jump to VB and am currently using Visual basic 2005 Express. > > > > Can anyone give me a snippet that will show me how to list the contents of > > a directory in a listbox. > > > > If you could also point me toward a good beginners VB 2005 book or website > > I would appreciate it. > > I'm still playing with this but: > > Dim S As String, I As Integer, L As ListViewItem, J As Long, T As Date > For I = 0 To CheckedListBox1.Items.Count - 1 > S = CheckedListBox1.Items(I) > dlgOpenFile.InitialDirectory = S > For Each foundFile As String In My.Computer.FileSystem.GetFiles( _ > S, FileIO.SearchOption.SearchAllSubDirectories, "*.*") > ListView2.Items.Add(foundFile) > L = ListView2.Items(ListView2.Items.Count - 1) > L.Checked = True > Next > > I'm using a ListView but a Listbox works too. > > > >
how to prevent multiple instances of 2nd form?
aggregation simple .net code column subtotals in a datagrid Wordwrap in VB.Net listbox? reuse query results for multiple object populations? (and dynamic variable names?) Crystal Report parameter dialog box ShouldSerialize problem in inherited control OFF TOPIC: Famous failed IT projects Webbrowser & XML Reading dll-Functions and execute them |
|||||||||||||||||||||||