Populate DropDownList
am 06.11.2007 20:33:20 von BenedictumIn a web site, I have a folder that contains text files (*.txt). I need to
get the server path and all files (txt type) and add it to a dropdown list
control. How do I do this?
In a web site, I have a folder that contains text files (*.txt). I need to
get the server path and all files (txt type) and add it to a dropdown list
control. How do I do this?
In VB.Net 2005, it's very simple - you could do it like this: Get the name of
the physical folder - use Server.MapPath if you don't know. Use the
My.Computer.FileSystem.GetFiles function to return a ReadOnlyCollection(of
String) containing the filenames of files in that folder. Loop thru
collection (For Each..). Check if the filename ends with .txt. If so add the
string to the combo.items collection using the add method.
Hope that makes sense.
Pete
"Benedictum" wrote:
> In a web site, I have a folder that contains text files (*.txt). I need to
> get the server path and all files (txt type) and add it to a dropdown list
> control. How do I do this?
>
>
>