By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,767 Members | 1,030 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,767 IT Pros & Developers. It's quick & easy.

VB.Net Code to read File Names

P: n/a
I want the VB.Net program to read and file names from a directory.

I thought the best thing to do was to place these file names into a
"temporary" MS Access database for sorting, etc.

So I'm looking for sample code that will instantiate MS Access (one that
only exists during the execution of the VB.Net program) and read and input
these file names from a directory into the Access table.

Thanks,
Mark

Nov 21 '05 #1
Share this Question
Share on Google+
6 Replies

P: n/a
Mark,
I want the VB.Net program to read and file names from a directory.

I thought the best thing to do was to place these file names into a
"temporary" MS Access database for sorting, etc.

Why seems for me very strange to use an external database for this with so
many posibilities in Net itself.

Cor
Nov 21 '05 #2

P: n/a
I know what you are saying. For example, read the names into an array or
collection and manipulate them - which is fine and I may do that.

I just thought why not learn how to automate Access from VB.Net, and see if
I can make it work.

Any suggestions on code that reads file names?

Thanks

"Cor Ligthert [MVP]" wrote:
Mark,
I want the VB.Net program to read and file names from a directory.

I thought the best thing to do was to place these file names into a
"temporary" MS Access database for sorting, etc.

Why seems for me very strange to use an external database for this with so
many posibilities in Net itself.

Cor

Nov 21 '05 #3

P: n/a
"Mark" <Ma**@discussions.microsoft.com> wrote in message
news:B3**********************************@microsof t.com...
I want the VB.Net program to read and file names from a directory.

I thought the best thing to do was to place these file names into a
"temporary" MS Access database for sorting, etc.


Sorry, but I *have* to disagree.

System.IO.Directory.GetFiles( "path", "pattern")

gets you a list (String array) of filenames.

To sort it, load the values into a SortedList and read them back.

HTH,
Phill W.
Nov 21 '05 #4

P: n/a
Phill,
GetFiles returns an array, you don't need a SortedList to sort it, you can
simply use Array.Sort to sort it.

Something like:

Dim files() As String = System.IO.Directory.GetFiles(".", "*.*")
Array.Sort(files)

Hope this helps
Jay
"Phill. W" <P.A.Ward@o-p-e-n-.-a-c-.-u-k> wrote in message
news:dc**********@yarrow.open.ac.uk...
| "Mark" <Ma**@discussions.microsoft.com> wrote in message
| news:B3**********************************@microsof t.com...
| > I want the VB.Net program to read and file names from a directory.
| >
| > I thought the best thing to do was to place these file names into a
| > "temporary" MS Access database for sorting, etc.
|
| Sorry, but I *have* to disagree.
|
| System.IO.Directory.GetFiles( "path", "pattern")
|
| gets you a list (String array) of filenames.
|
| To sort it, load the values into a SortedList and read them back.
|
| HTH,
| Phill W.
|
|
Nov 21 '05 #5

P: n/a
"Mark" <Ma**@discussions.microsoft.com> wrote in message
news:F7**********************************@microsof t.com...
I just thought why not learn how to automate Access from VB.Net,
and see if I can make it work.


"Automate" it?

If you mean programmatically making the Access program jump
through hoops, then I wish you well but, personally, I wouldn't bother.
To me, Access is *only* a database.

Regards,
Phill W.
Nov 21 '05 #6

P: n/a
Phil and Jay -

Thanks for the suggestions - they are too easy to pass-up.

Mark

"Phill. W" wrote:
"Mark" <Ma**@discussions.microsoft.com> wrote in message
news:B3**********************************@microsof t.com...
I want the VB.Net program to read and file names from a directory.

I thought the best thing to do was to place these file names into a
"temporary" MS Access database for sorting, etc.


Sorry, but I *have* to disagree.

System.IO.Directory.GetFiles( "path", "pattern")

gets you a list (String array) of filenames.

To sort it, load the values into a SortedList and read them back.

HTH,
Phill W.

Nov 21 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.