473,320 Members | 1,804 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

List Directories in ListBox

I am not very sure whether I should have continued with my earlier
thread or started a new thread whose subject matter was somewhat
similar to the subject matter in this thread. Anyway after much
deliberation, I decided to start a new thread. So here it is. Pardon me
if I should have continued with my earlier thread instead of starting
this new thread.

A ListBox lists all the directories & files existing in a directory on
the server. Assume that one of the directories is named the following:

"IHIS IS MY FOLDER"

The double quotes have been added just to show where the directory name
ends; it's not a part of the text.

But the ListBox displays the name of this directory as

"IHIS IS MY FOLDER"

i.e. the ListBox replaces all the whitespaces between words with a
single whitespace.

How do I make the ListBox retain the whitespaces present in the name of
the directory so that the directory listed in the ListBox displays
EXACTLY the same name as the name of the directory which exists in the
hard drive of the server? In other words, how do I make the ListBox
list the above directory as

"IHIS IS MY FOLDER"

& not as

"IHIS IS MY FOLDER"

Jan 6 '07 #1
3 2519
<rn**@rediffmail.comwrote in message
news:11*********************@q40g2000cwq.googlegro ups.com...
>I am not very sure whether I should have continued with my earlier
thread or started a new thread whose subject matter was somewhat
similar to the subject matter in this thread. Anyway after much
deliberation, I decided to start a new thread. So here it is. Pardon me
if I should have continued with my earlier thread instead of starting
this new thread.

A ListBox lists all the directories & files existing in a directory on
the server. Assume that one of the directories is named the following:

"IHIS IS MY FOLDER"

The double quotes have been added just to show where the directory name
ends; it's not a part of the text.

But the ListBox displays the name of this directory as

"IHIS IS MY FOLDER"

i.e. the ListBox replaces all the whitespaces between words with a
single whitespace.

How do I make the ListBox retain the whitespaces present in the name of
the directory so that the directory listed in the ListBox displays
EXACTLY the same name as the name of the directory which exists in the
hard drive of the server? In other words, how do I make the ListBox
list the above directory as

"IHIS IS MY FOLDER"

& not as

"IHIS IS MY FOLDER"
It's standard browser / HTML behaviour to ignore double spaces.

Try replacing each space with &nbsp; - I haven't tried this, though, so I
can't guarantee it'll work...
Jan 6 '07 #2
Mark, this is how I am populating the ListBox with directories & files:

Sub Page_Load(.....)
Dim dInfo As DirectoryInfo
dInfo = New DirectoryInfo(Server.MapPath("Folder1"))
lstFilesDirs.DataSource = dInfo.GetFileSystemInfos
lstFilesDirs.DataBind()
End Sub

Now how do I use the Replace string function while setting the
DataSource of the ListBox so that whitespaces get replaced with &nbsp;?

Moreover, I would like to add more information about each directory &
file listed in the ListBox. For e.g. if an item happens to be a
directory, I would like to add a string, say, <DIRon the same line
where the directory is listed in the ListBox. If an item happens to be
a file, I would like to add the size of the file along with the date &
time on which the file was created on the same line where the file is
listed in the ListBox. The ListBox should look something like this:

Folder1 <DIR>
Folder2 <DIR>
File1.aspx 22346 31/12/2006 5:34:11 AM
File2.aspx 7634 03/01/2007 8:24:52 PM
File3.aspx 2903 05/01/2007 1:16:33 PM

Any idea how do I append the additional info for each directory & file
on the same row where the directory & the file is listed respectively
in the ListBox?

I would like to request everyone to please view this post using the
fixed font. I guess that will give a better picture of how I want the
ListBox to look like with the additional info for each directory &
file.

I guess I am asking for too many favors. Sorry for the same.

Mark Rae wrote:
<rn**@rediffmail.comwrote in message
news:11*********************@q40g2000cwq.googlegro ups.com...
I am not very sure whether I should have continued with my earlier
thread or started a new thread whose subject matter was somewhat
similar to the subject matter in this thread. Anyway after much
deliberation, I decided to start a new thread. So here it is. Pardon me
if I should have continued with my earlier thread instead of starting
this new thread.

A ListBox lists all the directories & files existing in a directory on
the server. Assume that one of the directories is named the following:

"IHIS IS MY FOLDER"

The double quotes have been added just to show where the directory name
ends; it's not a part of the text.

But the ListBox displays the name of this directory as

"IHIS IS MY FOLDER"

i.e. the ListBox replaces all the whitespaces between words with a
single whitespace.

How do I make the ListBox retain the whitespaces present in the name of
the directory so that the directory listed in the ListBox displays
EXACTLY the same name as the name of the directory which exists in the
hard drive of the server? In other words, how do I make the ListBox
list the above directory as

"IHIS IS MY FOLDER"

& not as

"IHIS IS MY FOLDER"

It's standard browser / HTML behaviour to ignore double spaces.

Try replacing each space with &nbsp; - I haven't tried this, though, so I
can't guarantee it'll work...
Jan 6 '07 #3
<rn**@rediffmail.comwrote in message
news:11**********************@42g2000cwt.googlegro ups.com...
Mark, this is how I am populating the ListBox with directories & files:

Sub Page_Load(.....)
Dim dInfo As DirectoryInfo
dInfo = New DirectoryInfo(Server.MapPath("Folder1"))
lstFilesDirs.DataSource = dInfo.GetFileSystemInfos
lstFilesDirs.DataBind()
End Sub

Now how do I use the Replace string function while setting the
DataSource of the ListBox so that whitespaces get replaced with &nbsp;?
You can't - you'll need to add the items individually through code. That
will allow you to do any sort of string manipulation you like

http://community.strongcoders.com/fo...read/1477.aspx
Jan 6 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: chris vettese | last post by:
I have a table called table1 that has a one to many relationship to table2. What I would like to do is have a form with two list boxes on it. The first list box will have a field from all of the...
7
by: Dave Hopper | last post by:
Hi I posted a question recently regarding problems I am having getting a value from a list box to use in a query. I got a lot of help, for which I thank you and it's nearly working! But I need...
3
by: Brian Henry | last post by:
I have two list boxes on my form... lstCanSend and lstRecipients... well then there are two buttons add and remove between them (your basic select and pick listing) which uses java script to move...
11
by: Zorpiedoman | last post by:
The problem is this: I have a list box. I set an array list as the datasource. I remove an item from the array list. I set the listbox datasource to nothing. I set the listbox datasource to...
2
by: JIM.H. | last post by:
private void getList() { string fList = Directory.GetFiles("c:\\Tmp"); listBox.DataSource = fList; listBox.DataBind(); } This codes brings all the files in the folder c:\tmp. How can make...
2
by: pob | last post by:
Whats the difference between using a control or a listbox when looping thru a listbox. In example 1 it dims a listbox and an example 2 it dims a control. Please explain. Thanks in advance ...
2
by: Steve Potter | last post by:
I am trying to find some method of attaching a Listbox object to a list object so as the contents of the list are changed the contents of the Listbox will be updated to match. I have found a few...
6
by: kimiraikkonen | last post by:
Hello, I have a listbox and folder browser control. I need to display all .mp3 files' pathes into listbox. It was Ok with openfiledialog but how can list all .mp3 extension- having files into...
17
by: trose178 | last post by:
Good day all, I am working on a multi-select list box for a standard question checklist database and I am running into a syntax error in the code that I cannot seem to correct. I will also note...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.