Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

search for and display files ?

Status
Not open for further replies.

buddyel

MIS
Mar 3, 2002
279
US
I am trying to work on a asp.net page that will be on our company intranet.. Our company uses tons of flowcharts and i would like to create a page tha allows the user to enter some text in a textbox and have the program search a specified path for any filenames containing the text that was entered by the user and return the results in a datatable or some kind of table format on the page..

I would also like to have the filename be a link so that the user can click on the filename and it will open that file.. is this possible and if so where do i start?

Thanks in advance for any input....
 
You need to use the microsoft index server. If you have a search around microsofts site you should find a way of doing it. I did it at my old company with classic asp but have not had time to look round for a asp.net version. If you find one can you tell me here?

Thanks
 
imports system.io


dim files as string() = directory.getfiles("c://mydirectory")


The code above will give you an array of files that you can then work with however you like.

hth
-drew
 
yeah but thats going to be extremely slow if your searching inside the files for certain words.
 

I am not going to need to search within the file for text, i am just going to search the filename for certain text. That shouldn't slow down the search should it?
 
sorry no if it's just the filename then drews method is perfect. I'm not reading things straight at the moment :)
 
ok, i got the files to display in a datagrid on the page... now how can i have the filename be a hyperlink to the actual file so that the user can click on it and open the file ???
 
add an asp:hyperlinkcolumn to the datagrid and populate it with your info:

<Columns>
<asp:hyperlinkcolumn datanavigateurlfield=&quot;filename&quot; datatextfield=&quot;filename&quot;></asp:hyperlinkcolumn>
</Columns>

hth
-drew
 

Ok, this is what my code looks like so far...

Dim dir As New DirectoryInfo(&quot;C://flowcharts&quot;)
Dim f As FileInfo
For Each f In dir.GetFiles(&quot;*.flo&quot;)
Dim name As String = f.FullName
Dim size As Long = f.Length
Dim creationTime As DateTime = f.CreationTime
DataGrid1.DataSource = dir.GetFiles
DataGrid1.DataBind()
Next f

This code gives me all the following headings:
Extension
FullName
LastAccessTime
DirectoryName
LastWriteTime
Exists
Length
CreationTime
Name

What I would like is:
Name
Length
LastWriteTime


and i would like the Name field to be a hyperlink to be able to open the file. so where would i put the code that drew suggested ???

 
Sounds like you want to customize the datagrid to only show Databound fields...

Check this for more information.

You'll wanna turn off AutoGenerateColumns on the datagrid (
Code:
AutoGenerateColumns=&quot;False&quot;
, then do the hyperlink column like above. For the other colums:
Code:
<Columns>
 <asp:BoundColumn DataField=&quot;length&quot;></asp:BoundColumn>
</Columns>
...

You can use Property Builder if you are using VS.
HTH, Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top