468,505 Members | 1,772 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,505 developers. It's quick & easy.

Read Filenames from C:\Folder

guys, i need a little help with this.
this is working (well sort of)
i get the info, but it's not moving to a new line as it iterates thru the array
and all of the fields are like ONE HUGE LONG string
'declare an array

Dim filenames() As String
filenames = Directory.GetFiles("C:\Re_Class")
Dim i, o As Integer
Dim info As String

For i = 0 To filenames.Length - 1
'i do a substring to do away with the pathname

info += (filenames(i).Substring(12)) & ControlChars.CrLf
Next i

lstOne.Items.Add(info.ToString)

im then adding it to a list box. if i use a dropdown box the results are the same
this is a web app (asp.net/w/vb.net), just pulling file names from the root directory.
so, im getting info, i just need to have it start a new line on each iteration
thanks again
rik

************************************************** ********************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
Nov 19 '05 #1
2 8445
Hello rik,

Why not something like this:

Dim filenames() As String = Directory.GetFiles("C:\Re_Class")
Dim i, o As Integer
Dim filename As String

For i = 0 To filenames.Length - 1
filename = Path.GetFileName(filenames(i)) ' This is much better than
relying on substring to be accurate
lstOne.Items.Add(filename)
Next i

The problem with your code is that you are adding one string, rather than
individual strings. Each item in a list is one object.

--
Matt Berther
http://www.mattberther.com
guys, i need a little help with this.
this is working (well sort of)
i get the info, but it's not moving to a new line as it iterates thru
the array
and all of the fields are like ONE HUGE LONG string
'declare an array
Dim filenames() As String
filenames = Directory.GetFiles("C:\Re_Class")
Dim i, o As Integer
Dim info As String
For i = 0 To filenames.Length - 1
'i do a substring to do away with the pathname
info += (filenames(i).Substring(12)) & ControlChars.CrLf
Next i
lstOne.Items.Add(info.ToString)

im then adding it to a list box. if i use a dropdown box the results
are the same
this is a web app (asp.net/w/vb.net), just pulling file names from the
root directory.
so, im getting info, i just need to have it start a new line on each
iteration
thanks again
rik
************************************************** ********************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP &
ASP.NET resources...

Nov 19 '05 #2
absolutely awesome Matt.
works like a charm
thank you again
rik

************************************************** ********************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
Nov 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Edward K. Ream | last post: by
2 posts views Thread by =?Utf-8?B?SmVzcGVyLCBEZW5tYXJr?= | last post: by
colinod
8 posts views Thread by colinod | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by fmendoza | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.