473,796 Members | 2,425 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Selecting Multiple Files

Hi there,

I'm just starting at VB.NET (all VB come to that), and have what's probably
a very basic question:

I have a form in Visual Studio 2003 that has a listbox that is meant to be
populated with file names from the OpenFileDialog method (see below). The
problem is that if you select, say three files in the Open File dialogue
box, the listbox is populated with three of the same file rather than three
different files.

Any clues on where I'm going wrong?

Many thanks

John

Private Sub button1_Click(B yVal sender As Object, ByVal e As
System.EventArg s) Handles Button1.Click

Dim openFileDialog1 As New OpenFileDialog

Dim fName As String

openFileDialog1 .InitialDirecto ry = "c:\"

openFileDialog1 .Filter = "txt files (*.txt)|*.txt|A ll files (*.*)|*.*"

openFileDialog1 .FilterIndex = 2

openFileDialog1 .RestoreDirecto ry = True

openFileDialog1 .Multiselect = True

If openFileDialog1 .ShowDialog() = DialogResult.OK Then

For Each fName In openFileDialog1 .FileNames

lstWrkFiles.Ite ms.Add(openFile Dialog1.FileNam e)

Next

End If

End Sub
Nov 21 '05 #1
4 17488
John,

In your For Each loop:

lstWrkFiles.Ite ms.Add(fName)

Kerry Moorman

"John" wrote:
Hi there,

I'm just starting at VB.NET (all VB come to that), and have what's probably
a very basic question:

I have a form in Visual Studio 2003 that has a listbox that is meant to be
populated with file names from the OpenFileDialog method (see below). The
problem is that if you select, say three files in the Open File dialogue
box, the listbox is populated with three of the same file rather than three
different files.

Any clues on where I'm going wrong?

Many thanks

John

Private Sub button1_Click(B yVal sender As Object, ByVal e As
System.EventArg s) Handles Button1.Click

Dim openFileDialog1 As New OpenFileDialog

Dim fName As String

openFileDialog1 .InitialDirecto ry = "c:\"

openFileDialog1 .Filter = "txt files (*.txt)|*.txt|A ll files (*.*)|*.*"

openFileDialog1 .FilterIndex = 2

openFileDialog1 .RestoreDirecto ry = True

openFileDialog1 .Multiselect = True

If openFileDialog1 .ShowDialog() = DialogResult.OK Then

For Each fName In openFileDialog1 .FileNames

lstWrkFiles.Ite ms.Add(openFile Dialog1.FileNam e)

Next

End If

End Sub

Nov 21 '05 #2
That's great. Thanks very much Kerry.

Seems obvious now you point it out!

John
"Kerry Moorman" <Ke**********@d iscussions.micr osoft.com> wrote in message
news:B9******** *************** ***********@mic rosoft.com...
John,

In your For Each loop:

lstWrkFiles.Ite ms.Add(fName)

Kerry Moorman

"John" wrote:
Hi there,

I'm just starting at VB.NET (all VB come to that), and have what's
probably
a very basic question:

I have a form in Visual Studio 2003 that has a listbox that is meant to
be
populated with file names from the OpenFileDialog method (see below).
The
problem is that if you select, say three files in the Open File dialogue
box, the listbox is populated with three of the same file rather than
three
different files.

Any clues on where I'm going wrong?

Many thanks

John

Private Sub button1_Click(B yVal sender As Object, ByVal e As
System.EventArg s) Handles Button1.Click

Dim openFileDialog1 As New OpenFileDialog

Dim fName As String

openFileDialog1 .InitialDirecto ry = "c:\"

openFileDialog1 .Filter = "txt files (*.txt)|*.txt|A ll files (*.*)|*.*"

openFileDialog1 .FilterIndex = 2

openFileDialog1 .RestoreDirecto ry = True

openFileDialog1 .Multiselect = True

If openFileDialog1 .ShowDialog() = DialogResult.OK Then

For Each fName In openFileDialog1 .FileNames

lstWrkFiles.Ite ms.Add(openFile Dialog1.FileNam e)

Next

End If

End Sub

Nov 21 '05 #3
John,

In your For Each loop:

lstWrkFiles.Ite ms.Add(fName)

Kerry Moorman

"John" wrote:
Hi there,

I'm just starting at VB.NET (all VB come to that), and have what's probably
a very basic question:

I have a form in Visual Studio 2003 that has a listbox that is meant to be
populated with file names from the OpenFileDialog method (see below). The
problem is that if you select, say three files in the Open File dialogue
box, the listbox is populated with three of the same file rather than three
different files.

Any clues on where I'm going wrong?

Many thanks

John

Private Sub button1_Click(B yVal sender As Object, ByVal e As
System.EventArg s) Handles Button1.Click

Dim openFileDialog1 As New OpenFileDialog

Dim fName As String

openFileDialog1 .InitialDirecto ry = "c:\"

openFileDialog1 .Filter = "txt files (*.txt)|*.txt|A ll files (*.*)|*.*"

openFileDialog1 .FilterIndex = 2

openFileDialog1 .RestoreDirecto ry = True

openFileDialog1 .Multiselect = True

If openFileDialog1 .ShowDialog() = DialogResult.OK Then

For Each fName In openFileDialog1 .FileNames

lstWrkFiles.Ite ms.Add(openFile Dialog1.FileNam e)

Next

End If

End Sub

Nov 21 '05 #4
That's great. Thanks very much Kerry.

Seems obvious now you point it out!

John
"Kerry Moorman" <Ke**********@d iscussions.micr osoft.com> wrote in message
news:B9******** *************** ***********@mic rosoft.com...
John,

In your For Each loop:

lstWrkFiles.Ite ms.Add(fName)

Kerry Moorman

"John" wrote:
Hi there,

I'm just starting at VB.NET (all VB come to that), and have what's
probably
a very basic question:

I have a form in Visual Studio 2003 that has a listbox that is meant to
be
populated with file names from the OpenFileDialog method (see below).
The
problem is that if you select, say three files in the Open File dialogue
box, the listbox is populated with three of the same file rather than
three
different files.

Any clues on where I'm going wrong?

Many thanks

John

Private Sub button1_Click(B yVal sender As Object, ByVal e As
System.EventArg s) Handles Button1.Click

Dim openFileDialog1 As New OpenFileDialog

Dim fName As String

openFileDialog1 .InitialDirecto ry = "c:\"

openFileDialog1 .Filter = "txt files (*.txt)|*.txt|A ll files (*.*)|*.*"

openFileDialog1 .FilterIndex = 2

openFileDialog1 .RestoreDirecto ry = True

openFileDialog1 .Multiselect = True

If openFileDialog1 .ShowDialog() = DialogResult.OK Then

For Each fName In openFileDialog1 .FileNames

lstWrkFiles.Ite ms.Add(openFile Dialog1.FileNam e)

Next

End If

End Sub

Nov 21 '05 #5

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

Similar topics

3
2415
by: james.dixon | last post by:
Hi I was wondering if anyone else had had this problem before (can't find anything on the web about it). I have three select elements (list boxes - from here on I'll refer to them as 'the list boxes'). Users can add and remove items from the list boxes. When the users are adding and removing items, the list boxes are single
4
2683
by: Chris Jones | last post by:
Does anyone know of a C#/ASP.NET Open File dialog that I can use in an aspx page that allows multiselect? I need to be able to select and upload numerous files. Is there a reason why MS has made this so difficult? I am willing to pay for such a control.
1
4437
by: Olaf Baeyens | last post by:
In .NET v1.1 I am trying to select multiple files using OpenFileDialog like this OpenFileDialog openFileDialog=new OpenFileDialog(); openFileDialog.Multiselect=true; i f(openFileDialog.ShowDialog() == DialogResult.OK) { ... } Now I discover that there is a hardcoded limit of 200 files.
1
2242
by: Jay | last post by:
Hi All, My users are complaining about the page refreshing when they are selecting multiple rows in a datagrid. Has anyone tried to manage this using javascript? I tried smartnavigation but that caused me other problems. Any ideas? Thanks, Jay
1
2924
by: sneha123 | last post by:
There will be some 20 questions and for each question there will be 4 choices.what i want to do is to select multiple answers by clicking the checkbox. i m using asp.net,vb.net pls help me we have written the code using radio button for selecting single item.but we want to replace it with checkbox to select multiple items. the code using radio button is given below .pls correct it with checkbox
1
3356
by: Bob Loveshade | last post by:
I am looking for an example that shows how to select and highlight multiple rows in a DataGrid. My DataGrid is part of a Web User Control which is contained in an ASPX page. I haven't been able to find any examples which demonstrate how to do this. My Code:
0
373
by: John | last post by:
Hi there, I'm just starting at VB.NET (all VB come to that), and have what's probably a very basic question: I have a form in Visual Studio 2003 that has a listbox that is meant to be populated with file names from the OpenFileDialog method (see below). The problem is that if you select, say three files in the Open File dialogue box, the listbox is populated with three of the same file rather than three different files.
2
3664
by: areef.islam | last post by:
Hi, I am kinda new to javascript and I am having this problem with selecting multiple options from a select tag. Hope someone can help me out here. here is my code /////////////////////////////////////////////////////////////////////////////////////// <form action="whatever.php" method="post"> <select name="zip_code" onchange="makeRequest('getCity.php?state='+this.form.zip_code.options.value)" multiple="multiple" size="20">
2
1878
by: junaid | last post by:
Hi, please help me i want to select multiple files including directories using OpenFileDialog, but i cant get directory name(s) in FileNames property i am using J#, VS2005 are there any method to fulfill this using a dialog window like OpenFileDialog. any help please.
0
1517
TjFL
by: TjFL | last post by:
I have a form where specific external files are selected by the user depending on needs. Each item listed on the form has 4 Yes/No boxes next to it where they select what they want. The result will be multiple items having multiple files selected. I want to be able to then hit a command button and print the selected files. They consist of docs and pdfs which have hyperlinks saved in corresponding fields for each category. I'm at a loss...
0
10455
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...
0
10228
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10173
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
9052
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
6788
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
5441
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5573
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4116
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3731
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.