VB.Net Code to read File Names

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
 
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
 
Mark said:
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.
 
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


| | > 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.
|
|
 
Mark said:
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.
 
Phil and Jay -

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

Mark
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top