473,854 Members | 1,830 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

VB.Net Code to read File Names

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
6 24454
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
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
"Mark" <Ma**@discussio ns.microsoft.co m> wrote in message
news:B3******** *************** ***********@mic rosoft.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.Direc tory.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
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.Direc tory.GetFiles(" .", "*.*")
Array.Sort(file s)

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**@discussio ns.microsoft.co m> wrote in message
| news:B3******** *************** ***********@mic rosoft.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.Direc tory.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
"Mark" <Ma**@discussio ns.microsoft.co m> wrote in message
news:F7******** *************** ***********@mic rosoft.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 programmaticall y 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
Phil and Jay -

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

Mark

"Phill. W" wrote:
"Mark" <Ma**@discussio ns.microsoft.co m> wrote in message
news:B3******** *************** ***********@mic rosoft.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.Direc tory.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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
3513
by: deko | last post by:
I have a text file ("eighty.txt") that looks like this: 83|84|85|86 I can read the file into an array like this: $numbers= file("eighty.txt"); But how do I key the array? I'd like to use strings as keys: three, four, five, six - do I add the key names in the file?
3
5217
by: LELAND PRINCE | last post by:
Thanks, this group has been a big help. I need to create a backup copy of a working file that changes everyday, but I need to maintain a copy from each day. Would like to create: back1.txt back2.txt .. ..
1
2412
by: Stein | last post by:
I've seen a couple postings on moving files to folders with set source and destination paths, but I still need a little help taking it a step further. I have a folder with 2,000 Word docs that I generated using Word automation. Since the file names were generated from a table in Access, I would then like to use Access to sort those files into various folder based on names stored within the table. For example: There is a Word doc...
3
14541
by: Chris | last post by:
Hi, In C# I tried to save a file from a generated file name. Just before launching the dialog I check for a valid file name to be sure. There for I used the method ValidateNames from the save dialog. The strange thing is that sometimes the save dialogue
2
1399
by: JIM.H. | last post by:
Hello, I need to read all the files in current and sub folders and put it into a list box, is there any example in C# I can use?
31
2286
by: rbhlgjwbvi | last post by:
I have a header whose filename contains an embedded newline and I can't seem to #include it successfully. I've tried #include "my file.h" and #include "my\nfile.h"
1
1535
by: helraizer1 | last post by:
Hi all, I have a photography page on my website, I have pictures on the page (obviously) but the file names are stored and loaded in Javascript, in an array. var pic = new Array("./images/under1.png","./images/anemon.png","./images/arrow.png", "./images/babymoray.png","./images/grouper.png","./images/meridian.png", "./images/grouper1.png","./images/moray.png", "./images/morayeel.png", "./images/toitle.png", "./images/triggerfish.png",...
6
2408
by: angelicdevil | last post by:
how can i get the php to read the all the file names within a folder and put the names into an array?
2
3342
by: Ehsan arman | last post by:
I was wondering how I could read excel file names in a particular folder using Access VBA. I need to compare the file names in that folder with what I have in a field of Access table.
0
9903
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
11041
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10373
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...
1
7921
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7083
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
5753
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
5946
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4565
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4167
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.