[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Reterivieving all of the files from a directory

Posted on 2002-05-28
5
Medium Priority
?
211 Views
Last Modified: 2010-05-02
Hey Everyone...

Here what I am trying to do:

I have a directory with an ever changing number of txt files that I need to manipulate.  I need a way to collect all of the files of a certain extension(.msg) and read each file separately looking for a certain keyword(s).  Is there a way to read these files into an array and maniuplate them that way? or is their an easier way that I am missing.  Please let me know if you can help
0
Comment
Question by:dsplice
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 4

Accepted Solution

by:
gencross earned 400 total points
ID: 7040202
Something like this may do what you need.

    Dim sFile As String
    Dim sText As String
   
    Dim iFreeFile As Integer
   
    sFile = Dir("c:\*.txt")
   
    iFreeFile = FreeFile
   
    Do While sFile <> ""
       
        Open "c:\" & sFile For Input As iFreeFile
       
        sText = Input(LOF(iFreeFile), iFreeFile)
           
        If InStr(sText, "Look for") Then
            MsgBox "Text found"
        End If
       
        Close iFreeFile
       
        sFile = Dir
       
    Loop
0
 
LVL 22

Expert Comment

by:CJ_S
ID: 7040217
easy example:


Public function checkforkeyword(byval sPath as string, byval sKeyword as string)
Dim sFile as string, strBuf
sFile = Dir$("c:\*.msg")
Do While sFile<>""
   Open sFile For Binary As #lFile
   strBuff = Space$(LOF(lFile))
   Get #lFile, , strBuff
   Close #lFile
   If(InStr(1, strBuff, sKeyword)>0) Then msgbox sFile
   sFile = Dir$
Loop
end function

If it is for the web then I can really recommend index server for that which is from microsoft and allows exactly that. It may even have support for plain applications, though I am not sure of that.

CJ

0
 
LVL 53

Expert Comment

by:Ryan Chong
ID: 7040916
and use this to Reterivieving all of the files from a directory:

http://www.mvps.org/vbnet/code/fileapi/recursivefiles_minimal.htm
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7851208
Hi dsplice,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept gencross's comment(s) as an answer.

dsplice, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
0
 

Expert Comment

by:SpideyMod
ID: 7912829
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question