Monday, December 19, 2005

How to use Microsoft Indexing Service?

Using Microsoft Indexing Service:

Want to add document search in your application, you can use microsoft indexing service to do that. You can create a Catlog in the Microsoft indexing service on the folder whose document you want to search from your application. I will guide you on how to use microsoft indexing service from your ASP.NET page.

Go to Computer Management->Services and Application->Indexing Service and make sure that it is running.

You can create a new Catalg by Right Clicking the 'Indexing Service'. You can give a name to the catalog and browse to the folder which you want to be indexed by this catalog.

MS Indexing Service + ASP.NET
Creating an ASP.NET page that can query from the MS Indexing service, I will use the 'Web' catalog that is created by deafult by the indesing service on the 'c:\inetpub\wwwroot\' folder.

We can connect to the MS Indexing service through the following Connection String {"Provider=\"MSIDXS.1\";Data Source=;Integrated Security .="}

You can select the Name of the File, the path where it is located and some of the text from the file. {Select FileName,Path,Characterization from Scope()}

protected System.Data.OleDb.OleDbConnection oleDbConnection1;

this.oleDbConnection1.ConnectionString = "Provider=\"MSIDXS.1\";Data Source=Web;Integrated Security .=";

{You can change the 'Data Source' to the name of the catalog in which you want to search}

protected System.Data.OleDb.OleDbCommand oleDbSelectCommand3;
protected System.Data.OleDb.OleDbDataAdapter oleDbDataAdapter2;

this.oleDbSelectCommand3 = new System.Data.OleDb.OleDbCommand();
this.oleDbDataAdapter2 = new System.Data.OleDb.OleDbDataAdapter();

Sample Project:

Sample ASP.NET Project

Friday, December 16, 2005

What is .Resx file in Dot Net?

What is .Resx file in Dot Net??

It is an XML based file, with key value pair.

Reading from .Resx File:

You can access the .Resx file using this code:

ResXResourceReader reader = new ResXResourceReader(Server.MapPath("test.resx"));
IDictionaryEnumerator rsxr = reader.GetEnumerator();
foreach (DictionaryEntry d in reader)
Console.WriteLine(d.Key.ToString() + ":\t" + d.Value.ToString());
//Close the reader.

Writing to .Resx File:

We can write the binary data of an image to the .Resx file using the following code

Image img = Image.FromFile("urdu.jpg");
ResXResourceWriter rsxw = new ResXResourceWriter("urdu.resx");

Use of .Resx File:

It is very useful while working on Localized project [Multiple Languages], You can make different resource files for different languages and depending upon the user choice you can change the Language of the application.