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

(New to .NET) How do I load a directory of files into arraylist or collection?

Hello everybody,

I am beginning the .NET learning curve, and I have learned how to load
a listbox with a directory list of files using this code:

If FolderBrowserDialog1.ShowDialog() =
Windows.Forms.DialogResult.OK Then

ListBox1.DataSource =
System.IO.Directory.GetFiles(FolderBrowserDialog1. SelectedPath)

End If

But I do not actually need the listbox to be visible to the user for
what I am trying to do, and I would like to bypass it entirely by
looping through an arraylist or collection instead of looping through a
listbox. (I am going to do a routine that alters each file in the list
later).

So, my question for the pro's is, how would I have the list of files
load up in an arraylist or collection instead of the listbox?

Thank you very much in advance!

Sep 20 '06 #1
2 1795
AppleBag <ap******@gmail.comwrote:
Hello everybody,

I am beginning the .NET learning curve, and I have learned how to load
a listbox with a directory list of files using this code:

If FolderBrowserDialog1.ShowDialog() =
Windows.Forms.DialogResult.OK Then

ListBox1.DataSource =
System.IO.Directory.GetFiles(FolderBrowserDialog1. SelectedPath)

End If

But I do not actually need the listbox to be visible to the user for
what I am trying to do, and I would like to bypass it entirely by
looping through an arraylist or collection instead of looping through a
listbox. (I am going to do a routine that alters each file in the list
later).
Directory.GetFiles already returns an array - just don't put it into a
ListBox.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Sep 21 '06 #2
AppleBag,

If you want to avoid looping, than don't use a dotNet program language.

It cost no time for the computer and almost everything is based on that.

(Most end user tools do that for you behind the scene, although there are as
well a lot of methods in dotNet which do that for you).

Cor

"AppleBag" <ap******@gmail.comschreef in bericht
news:11**********************@i42g2000cwa.googlegr oups.com...
Hello everybody,

I am beginning the .NET learning curve, and I have learned how to load
a listbox with a directory list of files using this code:

If FolderBrowserDialog1.ShowDialog() =
Windows.Forms.DialogResult.OK Then

ListBox1.DataSource =
System.IO.Directory.GetFiles(FolderBrowserDialog1. SelectedPath)

End If

But I do not actually need the listbox to be visible to the user for
what I am trying to do, and I would like to bypass it entirely by
looping through an arraylist or collection instead of looping through a
listbox. (I am going to do a routine that alters each file in the list
later).

So, my question for the pro's is, how would I have the list of files
load up in an arraylist or collection instead of the listbox?

Thank you very much in advance!

Sep 22 '06 #3

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

Similar topics

11
by: DrUg13 | last post by:
In java, this seems so easy. You need a new object Object test = new Object() gives me exactly what I want. could someone please help me understand the different ways to do the same thing in...
1
by: Vagabond Software | last post by:
I am recursing through ALL folders and sub-folders below a certain level to list all the files of a certain type in those folders. I use two ArrayLists, alFiles and alFolders, to track matching...
2
by: Vladimir Oľura | last post by:
I am building a pocket pc application that requires a datagrid. I am inserting a new row this way: private void mInsert_Click(object sender, System.EventArgs e) { try { DataRow dr =...
6
by: LU | last post by:
I open new project from web (Created from another computer). I add new web form to project, build/rebuild etc and I get Parse error below. (If I change codebehind = to src=) it works. How do I get...
6
by: Bruce | last post by:
I am doing development work on an asp.net app and a web service on a Win XP Pro SP2 development workstation, using vs.net 2003. For reasons that I wont try to explain here, I recently moved the...
4
by: MS | last post by:
Hi. I'm new to developing and c#. I'm developing a tool that allows a user to select a directory with specially formatted files. The tool then iterates through the list of files in the directory...
12
by: Ron M. Newman | last post by:
Hi, I can load an assembly using the Assembly.Load(....) However, I'd like dynamic loading of assemblies to be identical to putting an assembly reference in your VS2005 project. and yes, I...
3
by: Kimera.Kimera | last post by:
I'm trying to write a program in VB.net 2003 that basically deletes all files, folders, sub-folders and sub-sub folders (etc). The program is simply for deleting the Windows/Temp folder contents,...
2
by: Vinod Sadanandan | last post by:
All, Below listed are the new features in Oracle 11g ,please join me in this discussion to generate a testcase and analyze each of the listed features . Precompilers:...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.