Hi Every One ,
1.its an Intranet application ..all the files(pdf,excel,text...etc) are maintained in an folder called "DAL"
2.in my home page i have an search button...when i search files it should only search in "DAL" Directory and have to display the searched files in a page..(upto here its working).
3.after displaying in an page i should have to download those searched files.
upto 2nd point its working ..just like read only...but i cant able to download..
i want to download those files after searching and displaying in the page..
here am attaching those .aspx and .aspx.cs files for referance.
* i feel those files should display in grid,repeater or as a links. but when i click file it should download.
c#.net :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.IO;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class SEARCH : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
{
string search = TextBox1.Text;
string[] files = Directory.GetFiles(@"F:\\abcd.co.in\DAL\", "*.*", SearchOption.AllDirectories);
int Flag = 0;
string dir = @"F:\\abcd.co.in\DAL\";
string[] files1;
int numFiles;
files1 = Directory.GetFiles(dir);
numFiles = files.Length;
Response.Write("Files searched : " + numFiles + "<br>");
for (int i = 0; i < numFiles; i++)
{
string file = files[i].ToString();
int file1 = file.IndexOf(search, StringComparison.CurrentCultureIgnoreCase);
if (file1 != -1)
{
Response.Write("<br>" + file);
Flag = 1;
}
}
if (Flag == 0)
{
Response.Write("No Matches Found");
}
}
}
}
inline code :
<pre lang="xml"><%@ Page Language="C#" AutoEventWireup="true" CodeFile="SEARCH.aspx.cs" Inherits="SEARCH" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
<br />
<br />
</div>
</form>
</body>
</html></pre>