473,671 Members | 2,510 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2545
<rn**@rediffmai l.comwrote in message
news:11******** *************@q 40g2000cwq.goog legroups.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(S erver.MapPath(" Folder1"))
lstFilesDirs.Da taSource = dInfo.GetFileSy stemInfos
lstFilesDirs.Da taBind()
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**@rediffmai l.comwrote in message
news:11******** *************@q 40g2000cwq.goog legroups.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**@rediffmai l.comwrote in message
news:11******** **************@ 42g2000cwt.goog legroups.com...
Mark, this is how I am populating the ListBox with directories & files:

Sub Page_Load(..... )
Dim dInfo As DirectoryInfo
dInfo = New DirectoryInfo(S erver.MapPath(" Folder1"))
lstFilesDirs.Da taSource = dInfo.GetFileSy stemInfos
lstFilesDirs.Da taBind()
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
2249
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 records in table1. When the user clicks on one of the records, the second list box will show all of the records related to that from table2. Is this possible? How can it be done. Regards, Chris Vettese
7
2574
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 a little more help on one more point. This is what i've got. I have code that hunts for updated appointments in a public folder based on the order that happens to be open (code fires on an on open event) This works fine and updates my
3
3095
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 the items between list boxes (the listbox controls are server side ones with runat=server set on them, the buttons are basic html button i dont want to post back each time someone clicks on add or remove... that wastes time and bandwidth) well the...
11
8548
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 the array list again to refresh. Click on an item in the list, and an Indexing error comes up. (in non-user code, it is trying to get an element from the array that is greater than the number of items in the array.) To reproduce:
2
1408
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 this code return all the files in the sub directories too?
2
16076
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 Example 1 from Allen Browne MVP Access To use a Multiselect list box for criteria for a report, you need to loop through its ItemsSelected collection to create a string that can act as the WhereCondition for your report.
2
2095
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 references to something like this in this old post http://groups.google.com/group/comp.lang.python/browse_thread/thread/3a6fe7534c812f55/43f201ab53cfdbf7 as well as here http://effbot.org/zone/wck-4.htm . It just seems that there should be some...
6
3152
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 my listbox using folder browser control. A sample code would be great.
17
3127
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 that I am using Allen Browne's multi-select list box for a report as a guide. I should also note that my access skills are not the best so I may need some explaining on certain things. First let me give some background on the database: I have a...
0
8397
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8919
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8599
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8670
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7439
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5696
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4409
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2052
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1810
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.