Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Read Filenames from C:\Folder

Reply
Thread Tools

Read Filenames from C:\Folder

 
 
rbutch@coair.com
Guest
Posts: n/a
 
      01-21-2005
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...
 
Reply With Quote
 
 
 
 
Matt Berther
Guest
Posts: n/a
 
      01-21-2005
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...



 
Reply With Quote
 
 
 
 
rbutch@coair.com
Guest
Posts: n/a
 
      01-21-2005
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...
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
read list of dirnames and search for filenames fscked Python 3 05-01-2007 10:47 PM
how to read Chinese filenames? ckyang74@gmail.com Perl Misc 5 06-06-2006 11:00 PM
problem with filenames, Filenames and FILENAMES B.J. HTML 4 04-23-2005 08:13 PM
Why can some browsers read filenames with spaces. Edison Carter HTML 1 09-30-2003 07:10 AM
All .packlist files contain relative filenames? moxie Perl 0 07-22-2003 04:15 PM



Advertisments