|
-
Apr 6th, 2005, 07:30 AM
#1
Thread Starter
Lively Member
[SOLVED]Search Text File
Hi, i'm making a little programme that is working absoluetly fine at the moment. It simply searches for certain files. Now I would like to know how to make it search for the files in a text file. So for example my text file looks like this:
file1.zip
file2.zip
How can i get VB to read that so I can search for it?
Thanks in advance!
Last edited by BefunMunkToloGen; Apr 6th, 2005 at 05:16 PM.
-
Apr 6th, 2005, 09:08 AM
#2
-
Apr 6th, 2005, 09:10 AM
#3
-
Apr 6th, 2005, 09:11 AM
#4
Junior Member
Re: Search Text File
I seems to me that you mean "search the 'zip' file" for a certain file name you specify.
If that is the case you need to get a zip control or zip dll that will allow you to call properties and methods for zip compressed files. Do a google search on zip control or zip dll and you will find lots. Here are a couple of examples:
http://www.abale.com/
http://www.bigspeed.net/index.php?page=bszipdll
I have used the second one and it works pretty well. Most are not free. Most will have a method that will list all the files in a zip without actually doing the extraction. You can then search the structure returned for the file you are after.
Hope that helps.
-
Apr 6th, 2005, 10:38 AM
#5
Thread Starter
Lively Member
Re: Search Text File
Thanks for the replies. I'm not looking for files inside zip files im just looking for file names, they are actually .pbo files. I will check them links out. Cheers
-
Apr 6th, 2005, 10:56 AM
#6
Thread Starter
Lively Member
Re: Search Text File
None of them seem to help. Say this is my text file:
1234.zip
2423.pbo
hello.txt
thanks.exe
I want to say line 1 of text file = line1
Line 2 (2434.pbo) of text file = line2
Search Line1
Search Line2
Search Line3
Etc? lol, hard to explain. Hope you understand.
Thanks
-
Apr 6th, 2005, 11:01 AM
#7
Re: Search Text File
open your file and use the Line Input statement.
VB Code:
Dim aline As String
Open "C:\yourfile.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, aline
'do whatever with the string aline
Loop
Close #1
casey.
-
Apr 6th, 2005, 12:24 PM
#8
Thread Starter
Lively Member
Re: Search Text File
Thanks Casey! Thats exactly what i needed!
-
Apr 6th, 2005, 01:14 PM
#9
Thread Starter
Lively Member
Re: [RESOLVED] - Search Text File
How can i do it to search more lines then one?
-
Apr 6th, 2005, 01:28 PM
#10
Re: [RESOLVED] - Search Text File
that will search each line one at a time.
casey.
-
Apr 6th, 2005, 01:31 PM
#11
Re: [RESOLVED] - Search Text File
I think you need to explain it better. If this is solved (which I don't think it is since the bottom post has a new question on it), please state it better. I personally don't understand.
Phreak
Visual Studio 6, Visual Studio.NET 2005, MASM
-
Apr 6th, 2005, 01:55 PM
#12
Thread Starter
Lively Member
Re: [RESOLVED] - Search Text File
Heres what I have
VB Code:
Private Sub tSearch_Timer()
txt.Caption = "Searching for ukf_infantry.pbo..."
Dim CSIDL As Long
Dim DefPath As String
DefPath = GetFolderPath(CSIDL_PROGRAM_FILES)
DefFold = DefPath & "\Codemasters\OperationFlashpoint\@ECP\Addons\"
Dim tempStr As String, Ret As Long
tempStr = String(MAX_PATH, 0)
Ret = SearchTreeForFile(DefFold, HOWD I PUT OUTPUT HERE??, tempStr)
If Ret <> 0 Then
With lst
.AddItem HOWD I PUT OUTPUT HERE?? & " - " & DefFold & "ukf_infantry"
End With
Else
End If
tSearch.Enabled = False
End Sub
Private Sub txtSearch_Click()
txtSearch.Enabled = False
Open (App.Path & "\flz.22") For Input As #1
Do While Not EOF(1)
Line Input #1, TLine
Loop
Close #1
defFol.Enabled = False
tSearch.Enabled = True
End Sub
I want it to search for the first line, third line, fifth line etc of what is in the text file. So basically, can i turn each line found from the text file into a global string?
-
Apr 6th, 2005, 02:03 PM
#13
Re: [RESOLVED] - Search Text File
as you are going through the loop, have a counter keeping record of which line you are on then check if the number is odd, if it is then add it to the string.
do you want an array or one long string of what you find ?
casey.
-
Apr 6th, 2005, 04:10 PM
#14
Thread Starter
Lively Member
Re: Search Text File
Say line one of the text is EXAMPLE i want to make that line into a string so i can do something like
Search examplestringname.
?? lol
-
Apr 6th, 2005, 04:27 PM
#15
Re: Search Text File
correct me if i am wrong, are you searching the textfile and if the line(filename) is a .pbo extension then add it to a listbox ?, if so then try this.
VB Code:
Dim TLine As String
Open (App.Path & "\flz.22") For Input As #1
Do While Not EOF(1)
Line Input #1, TLine
If Right$(TLine, 4) = ".pbo" Then
List1.AddItem TLine
End If
Loop
Close #1
casey.
-
Apr 6th, 2005, 04:47 PM
#16
Thread Starter
Lively Member
Re: Search Text File
No. Heres the situation. I need a programme to find out if a person has files missing in a certain folder. So if they don't have that file then it's added to the list. All the files are .pbo.
-
Apr 6th, 2005, 04:57 PM
#17
Re: Search Text File
if the certain folder is the same one all the time then use the Dir() function aswell to check if it exists, if it doesnt then add the item.
VB Code:
Dim TLine As String
Open (App.Path & "\flz.22") For Input As #1
Do While Not EOF(1)
Line Input #1, TLine
If Dir$("C:\thepath\tothe\folder\" & TLine) = "" Then
List1.AddItem TLine
End If
Loop
Close #1
is this it or am i just confused
casey.
-
Apr 6th, 2005, 05:08 PM
#18
Thread Starter
Lively Member
Re: Search Text File
I want to search a directory for files using the lines in the text file. lol im confusing myself.
-
Apr 6th, 2005, 05:13 PM
#19
Re: Search Text File
well you say your textfile as filenames so that code is taking each line which is a filename then adding it to the end of the string to the full folder path and checking if it exists.
If Dir$("C:\thepath\tothe\folder\" & TLine) = "" Then
is the folder where the files should be always the same ?
casey.
-
Apr 6th, 2005, 05:15 PM
#20
Thread Starter
Lively Member
Re: Search Text File
I see, it's late. Thats brilliant thanks a load
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|