interect with item

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;

namespace testApp
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string filename = Path.GetFileName(Request.Path);
            System.Diagnostics.Debug.WriteLine("filename: " + filename);



            string inputString;
            using (StreamReader streamReader = File.OpenText(Server.MapPath("~") + @"\menu.ini"))
            {
                inputString = streamReader.ReadLine();

                while (inputString != null)
                {

                    //int position = inputString.IndexOf("|");
                    //System.Diagnostics.Debug.WriteLine("position: " +position);


                    if (inputString.IndexOf("|") != -1)
                    {

                        string ClassWill = "";

                        //triming the string(removing the white space from the txt)
                        inputString.Trim();
                       
                        //spliting the string and convert into the arrary
                        string[] Content = inputString.Split('|');
                       
                        //checking the condition if both(link and the title) are not present then it will not generate the link
                        if (Content[0] != "" && Content[1] != "")
                        {

                            //setup the class name depend on the current page
                            if (filename == Content[1])
                            {
                                ClassWill = "class = \"active\"";
                            }
                            else {
                                ClassWill = "class = \"inactive\"";
                            }



                            ///starting the lavel and sublavel
                           

                            string tag = Content[0].Substring(0, 3);
                            System.Diagnostics.Debug.WriteLine("tag: " + tag);                          
                            //for 1 (-)
                            if (tag == "-") {
                                string str = "" + Content[0].Substring(Content[0].LastIndexOf('-') +1) +" ";
                                Label1.Text += str + "
";
                                System.Diagnostics.Debug.WriteLine("Item: " + str);                          
                            }
                            // for 2 (--)
                            else if (tag == "--") {
                                string str = "" + Content[0] + " ";
                                Label1.Text += str + "
";
                                System.Diagnostics.Debug.WriteLine("Item: " + str);
                            }
                            // for 3 (---)
                            else if (tag == "---")
                            {

                            }
                            //for security
                            else {

                                string str = "" + Content[0].Substring(Content[0].LastIndexOf('-') + 1) + " ";
                                Label1.Text += str + "
";
                                System.Diagnostics.Debug.WriteLine("Item: " + str);
                            }
                        }
                    }
                       
                    else
                    {
                        string str = "" + inputString + " ";
                        Label1.Text += str + "
";
                        System.Diagnostics.Debug.WriteLine("Item: " + str);                       
                    }

                    inputString = streamReader.ReadLine();  
                

                }
                //while loop finish
           
           
            }
            //reading the file finish
        }
        //page load finish   
   
    }
}

Comments

Popular posts from this blog

like php