473,386 Members | 1,699 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,386 software developers and data experts.

Multiple file selection into list window

1
I am VERY new to Scripting. All I am trying to do is have a button that lets me select a multiple files and then list them in a window below the button (for selection later). I have figured out how to at least OPEN the windows but when I select multiple files I get an error "NullReference Exception was unhandled"

Anyhow my starting code is below. Any assistance would be great. Thanks

Expand|Select|Wrap|Line Numbers
  1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  2.  
  3.         Dim openFileDialog1 As New OpenFileDialog
  4.         Dim fName As String
  5.  
  6.         openFileDialog1.InitialDirectory = "c:\"
  7.         openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"
  8.         openFileDialog1.FilterIndex = 2
  9.         openFileDialog1.RestoreDirectory = True
  10.         openFileDialog1.Multiselect = True
  11.  
  12.         If openFileDialog1.ShowDialog() = DialogResult.OK Then
  13.  
  14.             For Each fName In openFileDialog1.FileNames
  15.                 lstWrkFiles.Items.Add(fName)
  16.             Next
  17.         End If
Jun 27 '12 #1
1 1648
kadghar
1,295 Expert 1GB
debug it to check in what line you're getting the error.

I'll assume it's in the FOR, since the 'correct' syntax would be something like

For Each fName as [dunno this object] in openfiledialog1.Filenames

HTH
Jul 3 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Ringwraith | last post by:
Hi! Have anyone ever tried to modify the Gene Cash's Tkinter tree widget (available from http://home.cfl.rr.com/genecash/) so it supports multiple items selection ( selection of multiple files...
0
by: Pradyumna | last post by:
I have an application wherein I need to select multiple files. I am using a CFileDialog class for opening the 'Open file dialog' . However i cant seem to select more than 2605 files. I mean i can...
2
by: yanivoliver | last post by:
Hey, I'm currently trying to find a way to open a dialog box that will allow me to select more than one file at a time, so if I want to upload select all the files in a directory, I won't have...
3
by: abc | last post by:
Hello, Is there any way to select mutiple files from Client's machine's drive for uploading? Any help in this regards will be highly appreciated. Thanks in advance. Regards
7
by: mark2802 | last post by:
When using CMdialog control to open multiple filenames is there a way to force the order in whch the resulting filenames are returned? I require the filenames to be returned in the order they were...
15
by: Matt | last post by:
Is there a way to display the file selection window for a file input field via JavaScript? My goal is to emulate the behavior seen in Yahoo! Mail BETA. When adding an attachment, it displays a...
2
by: Prashant | last post by:
Hi All, we are using <input id="testFile" runat="server" type="file" /> control to select file from local machine. A problem with this control is at a time we can select only single file from...
1
by: goldtech | last post by:
Hi, TKinter question Let's say I use: .... files = tkFileDialog.askopenFilenames(filetypes=) .... This works OK - I can select multiple files and the var "files" will
2
by: klia | last post by:
Hello guys i was wondering how can i be able to have multiple file selection whenever i browse my directory and choose files using Qfiledailoug this is the code to lunch the file dailoug ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...

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.