
Retrieve names of TXT files from particular Folder through VB-6?
True, in many instances it would be better to use the FileSystemObject. It
is much more flexible and powerful and allows you to retrieve much more
information. But, in this instance where you only want the *.txt filenames
I would not suggest it. The problem of course is that you have a COM
object you have to create which adds to the resources your program takes up
and the processing time if it is a time critical app. It also adds another
component (scrrun.dll) that has to be distributed with the application.
The fact that Luqman further states that he doesn't want to use ActiveX
Controls indicates that he probably doesn't want the necessary requirements
that come with the FSO.
But, you are right, any other time you need to do file access it is usually
better and easier to use the FileSystemObject.
Kevin Williamson - Microsoft Visual Basic Support
--------------------
| Date: Thu, 09 Aug 2001 22:22:51 +0800
| X-Mailer: Mozilla 4.75 [en] (Win95; U)
| X-Accept-Language: en
| MIME-Version: 1.0
| Newsgroups: microsoft.public.vb.enterprise
| Subject: Re: Retrieve names of TXT files from particular Folder through
VB-6?
| Content-Type: text/plain; charset=us-ascii
| Content-Transfer-Encoding: 7bit
| NNTP-Posting-Host: dsp-202-72-133-25.perth.westnet.com.au
| X-Trace: quokka.wn.com.au 997421126
dsp-202-72-133-25.perth.westnet.com.au (9 Aug 2001 22:25:26 +0800)
| Lines: 54
| Path:
cppssbbsa01.microsoft.com!news-out.cwix.com!newsfeed.cwix.com!newsfeed.yosem
ite.net!nntp-relay.ihug.net!ihug.co.nz!newsfeed.germany.net!fu-berlin.de!new
sfeed.iinet.net.au!nntp.waia.asn.au!202.72.130.18.MISMATCH!quokka.wn.com.au
| Xref: cppssbbsa01.microsoft.com microsoft.public.vb.enterprise:61230
| X-Tomcat-NG: microsoft.public.vb.enterprise
|
| It's better to use the FileSystemObject and its Folder collection. Not
only can
| you iterate through the subfolders and files in a folder through separate
| collections, you can also query further information, such as size and
other
| attributes of each folder/file you examine. It's much more flexible, and
will
| will even return the total size of all subfolders and files contained by a
| folder with a single call (be careful with this one, as it skims through
the
| file system and can take some time if there's a lot in it - consider how
long it
| would take to skim through tens of thousands of files).
|
|
| > Luqman,
| >
| > You can use the Dir command. The following code will get all of the TXT
| > files from the root folder of the C drive:
| >
| > Private Sub Command1_Click()
| > Dim strFilename As String
| > strFilename = Dir("c:\*.txt")
| > While strFilename <> ""
| > Debug.Print strFilename
| > strFilename = Dir
| > Wend
| > End Sub
| >
| > Kevin Williamson - Microsoft Visual Basic Support
| >
| > --------------------
| > | Subject: Retrieve names of TXT files from particular Folder through
VB-6?
| > | Date: Sun, 5 Aug 2001 23:20:28 +0500
| > | Lines: 9
| > | X-Priority: 3
| > | X-MSMail-Priority: Normal
| > | X-Newsreader: Microsoft Outlook Express 5.00.2919.6600
| > | X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6600
| > | Newsgroups: microsoft.public.vb.enterprise
| > | NNTP-Posting-Host: 202.163.103.153
| > | Path: cppssbbsa01.microsoft.com!tkmsftngp01!tkmsftngp02
| > | Xref: cppssbbsa01.microsoft.com microsoft.public.vb.enterprise:61132
| > | X-Tomcat-NG: microsoft.public.vb.enterprise
| > |
| > | How can I retrieve names of TXT files from particular Folder through
VB-6,
| > | without using any ActiveX Control?
| > |
| > | Best Regards,
| > |
| > | Luqman
| > |
| > |
| > |
| > |
|
|