473,396 Members | 2,129 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Search Engine

27
Hi

In a web application , I need to create an aspx page(in C#) which can serach the files present on the server at the specified locations.

The search parameter may be the file name, extn name, location, fully or partly. The resulting file names should be displayed in a datagrid.

I am clueless about the functionality involved to create this search engine.

Can anyone help me?
Mar 28 '08 #1
2 962
kenobewan
4,871 Expert 4TB
Hi

In a web application , I need to create an aspx page(in C#) which can serach the files present on the server at the specified locations.

The search parameter may be the file name, extn name, location, fully or partly. The resulting file names should be displayed in a datagrid.

I am clueless about the functionality involved to create this search engine.

Can anyone help me?
The way this is normally done is through the use of metadata:
Metadata and Reflection in .NET
Mar 29 '08 #2
kbipul
27
The way this is normally done is through the use of metadata:
Metadata and Reflection in .NET

I could not get the task done . I have this sample code which is used to populate the gridview with the file names. This code is working fine


How can the results be filtered? Someone please edit the code so that it can filter the data. I am clueless.


using System;
using System.Text;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;


public partial class Test : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
lblErrorMsg.Text = "";

if (!IsPostBack)
{
try
{
string path;

if (Request.QueryString["PATH"] == null)
path = @"\\Process Database\Process Repository\Best Practices";
else
path = Server.UrlDecode(Request.QueryString["PATH"].ToString());

GridView1.DataSource = fillGridView(path);
GridView1.DataBind();

if(path.Equals(@"//DATAGRP/QAv21/QMS/Delivery/Quality Pebbles/Articles"))
{
lblErrorMsg.Text = "Quality Pebbles Articles";
lblErrorMsg1.Visible = true;
lblErrorMsg1.Text = "Quality Pebbles Answers";
path = @"\\DATAGRP\QAv21\QMS\Delivery\Quality Pebbles\Answer";
GridView2.DataSource = fillGridView(path);
GridView2.DataBind();
}

}
catch(QMSExceptions qmsex)
{
HandleQmsException(qmsex);
}
catch (Exception ex)
{
HandleException(ex);
}

}

}

private Names[] fillGridView(string path)
{
try
{
Names names = null;
object[] obj = null;
int gridRow = 0;
int index, docIndex;
int fileCounter = -1;
int directoryCount = -1;

DirectoryInfo dirInfo = new DirectoryInfo(path);

DirectoryInfo[] aryDirInfo = dirInfo.GetDirectories();
FileInfo[] aryFi = dirInfo.GetFiles();

int cnt;
cnt = aryFi.Length + aryDirInfo.Length;
if (cnt == 0)
throw new QMSExceptions("Directory is Empty");

int totalDocs = aryFi.Length + aryDirInfo.Length - 1;
if (cnt % 4 == 0)
cnt = cnt / 4;
else
cnt = (cnt / 4) + 1;
Names[] nameList = new Names[cnt];

for (index = 0; index <= totalDocs; index++)
{
if (index <= aryDirInfo.Length - 1)
{
obj = (DirectoryInfo[])aryDirInfo;
docIndex = directoryCount + 1;
directoryCount++;
}
else
{
obj = (FileInfo[])aryFi;
docIndex = fileCounter + 1;
fileCounter++;
}

names = new Names();
names.Name1 = ((System.IO.FileSystemInfo)(obj[docIndex])).Name;
if (obj.GetType().Name == "DirectoryInfo[]")
{
string paths = ((System.IO.FileSystemInfo)(obj[docIndex])).FullName.ToString();
paths = Server.UrlPathEncode(paths);
paths = paths.Replace("\\", "/");
names.Path1 = "javascript:openNewWindow('Test.aspx?PATH=" + paths + "')";
}
else
names.Path1 = ((System.IO.FileSystemInfo)(obj[docIndex])).FullName;

index += 1;
if (index > totalDocs)
{
nameList[gridRow] = names;
break;
}

if (index <= aryDirInfo.Length - 1)
{
obj = (DirectoryInfo[])aryDirInfo;
docIndex = directoryCount + 1;
directoryCount++;
}
else
{
obj = (FileInfo[])aryFi;
docIndex = fileCounter + 1;
fileCounter++;
}

names.Name2 = ((System.IO.FileSystemInfo)(obj[docIndex])).Name;
if (obj.GetType().Name == "DirectoryInfo[]")
{
string paths = ((System.IO.FileSystemInfo)(obj[docIndex])).FullName.ToString();
paths = Server.UrlPathEncode(paths);
paths = paths.Replace("\\", "/");
names.Path2 = "javascript:openNewWindow('Test.aspx?PATH=" + paths + "')";
}
else
names.Path2 = ((System.IO.FileSystemInfo)(obj[docIndex])).FullName;

index += 1;
if (index > totalDocs)
{
nameList[gridRow] = names;
break;
}

if (index <= aryDirInfo.Length - 1)
{
obj = (DirectoryInfo[])aryDirInfo;
docIndex = directoryCount + 1;
directoryCount++;
}
else
{
obj = (FileInfo[])aryFi;
docIndex = fileCounter + 1;
fileCounter++;
}

names.Name3 = ((System.IO.FileSystemInfo)(obj[docIndex])).Name;
if (obj.GetType().Name == "DirectoryInfo[]")
{
string paths = ((System.IO.FileSystemInfo)(obj[docIndex])).FullName.ToString();
paths = Server.UrlPathEncode(paths);
paths = paths.Replace("\\", "/");
names.Path3 = "javascript:openNewWindow('Test.aspx?PATH=" + paths + "')";
}
else
names.Path3 = ((System.IO.FileSystemInfo)(obj[docIndex])).FullName;

index += 1;
if (index > totalDocs)
{
nameList[gridRow] = names;
break;
}

if (index <= aryDirInfo.Length - 1)
{
obj = (DirectoryInfo[])aryDirInfo;
docIndex = directoryCount + 1;
directoryCount++;
}
else
{
obj = (FileInfo[])aryFi;
docIndex = fileCounter + 1;
fileCounter++;
}

names.Name4 = ((System.IO.FileSystemInfo)(obj[docIndex])).Name;
if (obj.GetType().Name == "DirectoryInfo[]")
{
string paths = ((System.IO.FileSystemInfo)(obj[docIndex])).FullName.ToString();
paths = Server.UrlPathEncode(paths);
paths = paths.Replace("\\", "/");
names.Path4 = "javascript:openNewWindow('Test.aspx?PATH=" + paths + "')";
}
else
names.Path4 = ((System.IO.FileSystemInfo)(obj[docIndex])).FullName;

nameList[gridRow] = names;
gridRow = gridRow + 1;
}
return nameList;

}
catch (Exception ex)
{
Names[] temp = null;
HandleException(ex);
return temp;
}
}

private void HandleQmsException(QMSExceptions hqmsex)
{
lblErrorMsg.Text = hqmsex.Message.Replace(":", "-");
}

private void HandleException(Exception hex)
{
lblErrorMsg.Text = hex.Message.Replace(":", "-");
}
}
Mar 31 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Rod | last post by:
Hi, i am doing a ecommerce website and would like to implement a search engine to find products. All the serach engine I have found on the web are parsing html page! This is not what i want. i...
0
by: R. Rajesh Jeba Anbiah | last post by:
Q: Is PHP search engine friendly? Q: Will search engine spiders crawl my PHP pages? A: Spiders should crawl anything provided they're accessible. Since, nowadays most of the websites are been...
11
by: Petre Huile | last post by:
I have designed a site for a client, but they have hired an internet marketing person to incrase their search engine ranking and traffic. He wants to put extra-large fonts on every page which will...
5
by: George | last post by:
Hi, Anyone has the background for explaining? I have made a search on my name and I have got a link to another search engine. The link's title was the search phrase for the other search engine...
14
by: vic | last post by:
My manager wants me to develop a search program, that would work like they have it at edorado.com. She made up her requirements after having compared how search works at different websites, like...
2
by: Patrick | last post by:
Are the differences between a search engine, a subject directory and a meta search engine significant for an ebusiness web site owner? A meta search engine merely uses ordinary existing search...
5
by: Sam | last post by:
Does anyone know of a way to create a search page under ASP.NET 2.0? I have started out by configuring a catalog in Index Server, registering the aspx, ascx extensions in the registry to allow...
64
by: Manfred Kooistra | last post by:
I am building a website with identical content in four different languages. On a first visit, the search engine determines the language of the content by the IP address of the visitor. What the...
3
by: hazly | last post by:
I'm very new in the web technology and need advice on search engine. I want to develop a portal using PHP and MySQL on Linux. Need to know on the following features : 1. search engine that could...
4
by: MDW | last post by:
Posted this on another board, but evidently it was off-topic there...hope you folks will be able to provide some guidance. I've been working on a Web site for a business (my first non-personal...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.