|
-
Jun 11th, 2007, 08:09 AM
#1
Thread Starter
Fanatic Member
file system search program
I am trying to create a program that does a file system search.
I have a form that has three textboxes and a data grid and a search button.
One text box has the date and another has the month and the thrid contains the year. Upon clicking the search button a data grid gets populated on the form via the search that shows the file information which is in a pdf format shoudla user enter in a year that matches it pulls up all the files under that files and shows them in the grid..if they enter a month it shows all information under that month. Bu that's about all..can anyone help me figure out what I might need to do next exactly ? Or perhaps someone has an example handy that gives me an idea of what needs to be done ?
Now I remembered from last week that I would need the following in a subroutine:
Dim objStream As New FileStream(" file path", FileMode.Open)
Dim objReader As New StreamReader(objStream)
Dim strBuffer As String
strBuffer = objReader.ReadToEnd
objReader.Close()
objStream.Close()
MsgBox(strBuffer)
-
Jun 11th, 2007, 08:15 AM
#2
Fanatic Member
Re: file system search program
where are you making the search? in a specific folder or in all the available drives? Does the search need to search the subfolders as well?
When you find a file that matches the pdf extension, you need a fileInfo object to retrieve the date information about the file and then extract the value that you are looking for to compare it to the user input
-
Jun 11th, 2007, 08:28 AM
#3
Thread Starter
Fanatic Member
Re: file system search program
 Originally Posted by talkro
where are you making the search? in a specific folder or in all the available drives? Does the search need to search the subfolders as well?
When you find a file that matches the pdf extension, you need a fileInfo object to retrieve the date information about the file and then extract the value that you are looking for to compare it to the user input
I am searching in a specific folder where all the pdfs are contained. There are no subfolders. A fileInfo object ?Would this need to be incorporated in the code I have above ? How would this be stated in code format exactly ? For example would this be contained the btnSearch click event ?
-
Jun 11th, 2007, 08:45 AM
#4
Fanatic Member
Re: file system search program
this will be contained in the btnSearch and you can check this link for more info
-
Jun 11th, 2007, 08:57 AM
#5
Thread Starter
Fanatic Member
Re: file system search program
 Originally Posted by talkro
this will be contained in the btnSearch and you can check this link for more info
Ok. I looked back in the threads here and found this code.
Code:
1. Private Sub RecFileSearch(ByVal dir As String)
2. Try
3. Dim di As New DirectoryInfo(dir)
4. Dim fi() As FileInfo
5. fi = di.GetFiles
6. For X As Integer = 0 To fi.Length - 1
7. ListBox1.Items.Add(fi(X).FullName) 'Your code for each file goes here.
8. Next
9. Dim DirectoryArray() As DirectoryInfo
10. DirectoryArray = di.GetDirectories
11. If DirectoryArray.Length > 0 Then
12. For i As Integer = 0 To DirectoryArray.Length - 1
13. RecFileSearch(DirectoryArray(i).FullName)
14. Next
15. End If
16. Catch ex As FileNotFoundException
17. 'Ignore any File not found - sometimes Temp files show in the DirectoryInfo/FileInfo
18. ' then are gone by the time the loop tries to get info on them.
19. Catch ex As Exception
20. MsgBox("There was an error:" + ex.ToString) 'Ordinarily "System Volume Information" will throw this exception as an Access Exception.. You can handle that how you want.
21.
22. End Try
23.
24. End Sub
-
Jun 11th, 2007, 09:13 AM
#6
Fanatic Member
Re: file system search program
in your case, you only need to use the first loop and instead of adding to the listbox directly, you first use the members of the fileInfo class to find if the file matches the criteria and then you add the needed info in you viewer
-
Jun 11th, 2007, 09:22 AM
#7
Thread Starter
Fanatic Member
Re: file system search program
 Originally Posted by talkro
in your case, you only need to use the first loop and instead of adding to the listbox directly, you first use the members of the fileInfo class to find if the file matches the criteria and then you add the needed info in you viewer
I must admit you have me confused with your last statement here.
Wouldn't I use the following to find what I needed ? This is a snippet from some code for my datagrid.
Code:
<%@ Import Namespace="System.IO" %>
<script language="VB" runat="server">
Sub Page_Load(sender as Object, e as EventArgs)
Dim dirInfo as New DirectoryInfo(Server.MapPath(""))
articleList.DataSource = dirInfo.GetFiles("*.aspx")
articleList.DataBind()
End Sub
</script>
The second line in boldface grabs all of the files with the .aspx extensions. And then binds this information to the datagrid named articlelist.
-
Jun 11th, 2007, 09:30 AM
#8
Fanatic Member
Re: file system search program
i though you already had the path where to search and that you are looking for some files that either match the year or the month enter by the user?
Otherwise your are write. my bad
-
Jun 11th, 2007, 09:32 AM
#9
Re: file system search program
I've have made a File search app and posted the code here http://www.vbforums.com/showthread.php?t=455148. This should help with some of your questions.
-
Jun 11th, 2007, 09:47 AM
#10
Thread Starter
Fanatic Member
Re: file system search program
 Originally Posted by talkro
i though you already had the path where to search and that you are looking for some files that either match the year or the month enter by the user?
Otherwise your are write. my bad
Hey.I just didn't write in the filepath I was using in the line of code. So it isn't your bad quite yet.
-
Jun 11th, 2007, 09:48 AM
#11
Thread Starter
Fanatic Member
Re: file system search program
 Originally Posted by ProphetBeal
I should have put this in the ASP.net forum as this will turn out to be a web application so I wonder if the same that you have here applies.
-
Jun 11th, 2007, 10:29 AM
#12
Thread Starter
Fanatic Member
Re: file system search program
Ok. I tested my code in the page load event of the application to see if the datagrid woudl grab everything in the file folder and it did.
Now I need to put this logic in my btn Search and then have the program anticipate what file from the folder will be pulled based on the date or month or year entered and then the Search button clicked. I might have to filter my results from a data table.
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
|