473,396 Members | 2,018 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,396 software developers and data experts.

Files-listbox

Hello,

I have a lisbox placed on a form, in the listbox i want to
get the filenames of a specific directory.

So if i have 3 files in directory "c:\Test", i want to be
able to select them in the listbox.

I think I have to count the number of files in the
directory, and then per file adding them as item...

Well it's just simple mindspinning of me, but i haven't
got a clue how to get it working...

Can anyone help me please....
Nov 20 '05 #1
7 1519
Cor
Hi Niels,

Have a look at

http://msdn.microsoft.com/library/de...classtopic.asp

And to

(Addrange)

http://msdn.microsoft.com/library/de...classtopic.asp

It should be very simple with this information.

I hope this helps?

Cor
Nov 20 '05 #2
-----Original Message-----
Hi Niels,

Have a look at

http://msdn.microsoft.com/library/default.asp? url=/library/en-
us/cpref/html/frlrfsystemiodirectoryinfoclasstopic.asp
And to

(Addrange)

http://msdn.microsoft.com/library/default.asp? url=/library/en-
us/cpref/html/frlrfsystemwindowsformslistboxobjectcollectio
nclasstopic.asp
It should be very simple with this information.

I hope this helps?

Cor
.

Thanks for your reaction, but it is not so very simple for
a beginner...

I watched the code, and got a few lines of code working

Private Sub Button1_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
MyPath = Application.StartupPath
Dim Dirs As DirectoryInfo = New DirectoryInfo
(MyPath & "\Stamps\")
Dim FileCount As FileSystemInfo() =
Dirs.GetFiles
Dim Count As Integer
Count = FileCount.Length - 1

Dim ItemObject(Count) As System.Object
Dim i As Integer
For i = 0 To Count
ItemObject(i) = FileName ' "FullName" geeft
het path: "Name" geeft directorynaam
Next i
ComboBox1.Items.AddRange(ItemObject)
End Sub
But this code gives the path instead of the filenames..

Can anyone help me again please...
Nov 20 '05 #3
-----Original Message-----
Hi Niels,

Have a look at

http://msdn.microsoft.com/library/default.asp? url=/library/en-
us/cpref/html/frlrfsystemiodirectoryinfoclasstopic.asp
And to

(Addrange)

http://msdn.microsoft.com/library/default.asp? url=/library/en-
us/cpref/html/frlrfsystemwindowsformslistboxobjectcollectio
nclasstopic.asp
It should be very simple with this information.

I hope this helps?

Cor
.

Thanks for your reaction, but it is not so very simple for
a beginner...

I watched the code, and got a few lines of code working

Private Sub Button1_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
MyPath = Application.StartupPath
Dim Dirs As DirectoryInfo = New DirectoryInfo
(MyPath & "\Stamps\")
Dim FileCount As FileSystemInfo() =
Dirs.GetFiles
Dim Count As Integer
Count = FileCount.Length - 1

Dim ItemObject(Count) As System.Object
Dim i As Integer
For i = 0 To Count
ItemObject(i) = FileName ' "FullName" geeft
het path: "Name" geeft directorynaam
Next i
ComboBox1.Items.AddRange(ItemObject)
End Sub
But this code gives the path instead of the filenames..

Can anyone help me again please...
Nov 20 '05 #4
you can use Microsoft.VisualBasic.Compatibility.VB6.FileListBo x

an*******@discussions.microsoft.com wrote:
-----Original Message-----
Hi Niels,

Have a look at

http://msdn.microsoft.com/library/default.asp?


url=/library/en-
us/cpref/html/frlrfsystemiodirectoryinfoclasstopic.asp
And to

(Addrange)

http://msdn.microsoft.com/library/default.asp?


url=/library/en-
us/cpref/html/frlrfsystemwindowsformslistboxobjectcollectio
nclasstopic.asp
It should be very simple with this information.

I hope this helps?

Cor
.


Thanks for your reaction, but it is not so very simple for
a beginner...

I watched the code, and got a few lines of code working

Private Sub Button1_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
MyPath = Application.StartupPath
Dim Dirs As DirectoryInfo = New DirectoryInfo
(MyPath & "\Stamps\")
Dim FileCount As FileSystemInfo() =
Dirs.GetFiles
Dim Count As Integer
Count = FileCount.Length - 1

Dim ItemObject(Count) As System.Object
Dim i As Integer
For i = 0 To Count
ItemObject(i) = FileName ' "FullName" geeft
het path: "Name" geeft directorynaam
Next i
ComboBox1.Items.AddRange(ItemObject)
End Sub
But this code gives the path instead of the filenames..

Can anyone help me again please...


Nov 20 '05 #5
you can use Microsoft.VisualBasic.Compatibility.VB6.FileListBo x

an*******@discussions.microsoft.com wrote:
-----Original Message-----
Hi Niels,

Have a look at

http://msdn.microsoft.com/library/default.asp?


url=/library/en-
us/cpref/html/frlrfsystemiodirectoryinfoclasstopic.asp
And to

(Addrange)

http://msdn.microsoft.com/library/default.asp?


url=/library/en-
us/cpref/html/frlrfsystemwindowsformslistboxobjectcollectio
nclasstopic.asp
It should be very simple with this information.

I hope this helps?

Cor
.


Thanks for your reaction, but it is not so very simple for
a beginner...

I watched the code, and got a few lines of code working

Private Sub Button1_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
MyPath = Application.StartupPath
Dim Dirs As DirectoryInfo = New DirectoryInfo
(MyPath & "\Stamps\")
Dim FileCount As FileSystemInfo() =
Dirs.GetFiles
Dim Count As Integer
Count = FileCount.Length - 1

Dim ItemObject(Count) As System.Object
Dim i As Integer
For i = 0 To Count
ItemObject(i) = FileName ' "FullName" geeft
het path: "Name" geeft directorynaam
Next i
ComboBox1.Items.AddRange(ItemObject)
End Sub
But this code gives the path instead of the filenames..

Can anyone help me again please...


Nov 20 '05 #6
Cor
Hi Niels,

I missed your answer I see now, sorry was not intended.

Try this and do absolutly not use for new things the compatible visual basic
namespace
\\\
Private Sub Button1_Click(ByVal sender As _
System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim mypath As String
mypath = Application.StartupPath
Dim Dirs As IO.DirectoryInfo = New IO.DirectoryInfo(mypath &
"\Stamps\")
Dim FileCount As IO.FileSystemInfo() = Dirs.GetFiles
Dim FileNaam As IO.FileInfo
ComboBox1.Items.Clear()
ComboBox1.Items.AddRange(FileCount)
ComboBox1.SelectedIndex = 0
End Sub
///
I hope this helps?

Cor
Nov 20 '05 #7
Cor
Hi Niels,

I missed your answer I see now, sorry was not intended.

Try this and do absolutly not use for new things the compatible visual basic
namespace
\\\
Private Sub Button1_Click(ByVal sender As _
System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim mypath As String
mypath = Application.StartupPath
Dim Dirs As IO.DirectoryInfo = New IO.DirectoryInfo(mypath &
"\Stamps\")
Dim FileCount As IO.FileSystemInfo() = Dirs.GetFiles
Dim FileNaam As IO.FileInfo
ComboBox1.Items.Clear()
ComboBox1.Items.AddRange(FileCount)
ComboBox1.SelectedIndex = 0
End Sub
///
I hope this helps?

Cor
Nov 20 '05 #8

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

Similar topics

2
by: Mike | last post by:
I am sure that I am making a simple boneheaded mistake and I would appreciate your help in spotting in. I have just installed apache_2.0.53-win32-x86-no_ssl.exe php-5.0.3-Win32.zip...
0
by: Tom Lee | last post by:
Hi, I'm new to .NET 2003 compiler. When I tried to compile my program using DEBUG mode, I got the following errors in the C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7 \include\xdebug...
18
by: JKop | last post by:
Here's what I know so far: You have a C++ project. You have source files in it. When you go to compile it, first thing the preprocessor sticks the header files into each source file. So now...
18
by: UJ | last post by:
Folks, We provide custom content for our customers. Currently we put the files on our server and people have a program we provide that will download the files. These files are usually SWF, HTML or...
3
by: aRTx | last post by:
I have try a couple of time but does not work for me My files everytime are sortet by NAME. I want to Sort my files by Date-desc. Can anyone help me to do it? The Script <? /* ORIGJINALI
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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...
0
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,...

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.