Click here to Skip to main content
15,879,535 members
Articles / Programming Languages / C#
Tip/Trick

Making Site Address Finder in C#

Rate me:
Please Sign up or sign in to vote.
4.45/5 (9 votes)
12 Aug 2013CPOL3 min read 20K   749   8   8
Address Finder is a kind of program that helps the user to find new available URL of a website.
Image 1

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!

  1. 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.
  2. 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.
  3. 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:
    C#
    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.

  4. Last Step: All done successfully. Also, you can add a button for going to detected URL like below code:
    C#
    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:

Image 2

Image 3

Also, you can download this example source code from links which are placed at the top of the page.

Image 4

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.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Iran (Islamic Republic of) Iran (Islamic Republic of)
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
Question[My vote of 1] Lang?! Pin
David H. Wright13-Aug-13 6:18
professionalDavid H. Wright13-Aug-13 6:18 
AnswerRe: [My vote of 1] Lang?! Pin
Amir Mohammad Nasrollahi13-Aug-13 7:12
professionalAmir Mohammad Nasrollahi13-Aug-13 7:12 
The pictures are not important for understanding content of article. i use Persian images just for showing some other samples which i create before and for main sample of article (with source) i wrote a program with international language (last picture).
Anyway i think just language of pictures is not good reason for voting 1.

Regards
-Amir Mohammad Nasrollahi
/* LIFE RUNS ON CODE */

GeneralRe: [My vote of 1] Lang?! Pin
David H. Wright14-Aug-13 0:56
professionalDavid H. Wright14-Aug-13 0:56 
AnswerRe: [My vote of 1] Lang?! Pin
Amir Mohammad Nasrollahi14-Aug-13 3:38
professionalAmir Mohammad Nasrollahi14-Aug-13 3:38 
GeneralMy vote of 5 Pin
ketan italiya12-Aug-13 21:44
ketan italiya12-Aug-13 21:44 
GeneralRe: My vote of 5 Pin
Amir Mohammad Nasrollahi12-Aug-13 23:05
professionalAmir Mohammad Nasrollahi12-Aug-13 23:05 
GeneralMy vote of 5 Pin
Reza Khan Mohammad12-Aug-13 10:49
professionalReza Khan Mohammad12-Aug-13 10:49 
GeneralRe: My vote of 5 Pin
Amir Mohammad Nasrollahi12-Aug-13 10:51
professionalAmir Mohammad Nasrollahi12-Aug-13 10:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.