473,785 Members | 2,789 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 17478
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
4436
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
2923
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
3354
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
3663
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
9645
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9481
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,...
1
10095
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
9953
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
8978
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
6741
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
5383
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
5513
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2881
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.