Introduction
What is address finder? Address finder is a kind of program that helps the user to find new available URL of a website. It can be useful when we want to change our current web URL or it expired and we want to show our new available web address to users. Other good usages of address finder is in some countries which websites become filter in that places and admins want to show users their new address.
Anyway, Address Finder algorithm is a good example for beginners practice.
Background
Generally, most of Address Finder programs algorithms are based on text file stream reading which are located in a host. By this, admin can write new address on that text file and new address will be shown to user who uses that address finder.
Some other advanced address finders are made from two parts. The first part is under user control and user can read address by that and the second part is under admin control and he can write new address to main source. Also this address finder is included with ads and some useful features.
Actually for offering address finders, admin must put address finder download link in a place where user downloads it and after that, the user can open it in order to see new available address.
Using the Code
I subdivide the way of creating Address Finder to some basic steps which can do them easily. Also, you must have noticed that I am talking about the easiest way of making Address Finder and in other methods, you can do something else. Now, it is time for coding!
- First Step: At first, we need to create a text file with Notepad and then add URL address (which we want to show as new address to user) to it. For example, I create link.txt and then type www.filmbinha.ir to it.
- Second Step: Now you must upload that text file to a trusted host. In this example, my uploaded link is http://adyab.sourcenevis.ir/Adress.txt.
- Third Step: Now, in our C# solution, we must add a button and code in order to read that text file which is now uploaded to a specific host. My code in button click event:
try
{
System.Net.WebClient WebClient = new System.Net.WebClient();
WebClient.DownloadFile("http://adyab.sourcenevis.ir/Adress.txt", @"link.txt");
StreamReader reader = new StreamReader(@"link.txt");
string URLvalue = reader.ReadToEnd();
reader.Close();
reader.Dispose();
textBox1.Text = URLvalue;
}
catch { }
Code Explanation: In this method, we start reading our text file on internet host by using a StreamReader
. It is designed for character input in a particular encoding, whereas the Stream
class is designed for byte input and output. We can use StreamReader
for reading lines of information from a standard text file. More
Also, don't forget that StreamReader
class needs System.IO
using.
- Last Step: All done successfully. Also, you can add a button for going to detected URL like below code:
if (textBox1.Text != "")
{
try
{
System.Diagnostics.Process.Start(textBox1.Text);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
else
{
MessageBox.Show("At first please push 'Search' button please.");
}
Now, your Address Finder is finished and you can work on its graphic. Mine & my friend's Address Finder are like below:
Also, you can download this example source code from links which are placed at the top of the page.
Usage
As I mentioned before, Address Finders are good programs (especially in countries with site filtering policy) for finding new available URL of website and also its algorithm can be informative for beginner programmers. For example, in Iran, all of Music and Movie download centers use address finder to show their new address to users.
Article in other Languages
Iranian members or readers of CodeProject can download the Persian video tutorial of this tip by clicking here and also they can read the Persian version of this tip from this link.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.