Search this blog

You can search for all the topics in our blog using our google custom search now.

Search the blog

Loading

Thursday, September 9, 2010

How to create Custom Installers?

Hi,

This video tutorial will show you how to create custom installers. This example uses topic from Logging Application State, if you haven't seen its example.Check out the below link:

Logging and System Management

I have divided the tutorial in two part. The links are below:
1. How to create Custom Installers Part 1
2. How to create Custom Installers Part 2

How to create Custom Installers Part 2



Code for MyInstaller.cs class is as given below :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration.Install;
using System.ComponentModel;
using System.Collections;
using System.Diagnostics;

namespace SimpleApplication
{
    [RunInstaller(true)]
    public class MyInstallerClass : Installer
    {

        public MyInstallerClass()
            : base()
        { }

        public override void Commit(IDictionary savedState)
        {
            base.Commit(savedState);
        }

        public override void Install(IDictionary stateSaver)
        {
            base.Install(stateSaver);
            CreateEventLog();
        }
        public override void Rollback(IDictionary savedState)
        {
            base.Rollback(savedState);
            DeleteEventLog();
        }
        public override void Uninstall(IDictionary savedState)
        {
            base.Uninstall(savedState);
            DeleteEventLog();
        }

        public void CreateEventLog()
        {
            if (!EventLog.Exists("SimpleApplication Log"))
            {
                EventLog.CreateEventSource("SimpleApplication", "SimpleApplication Log");
            }
        }

        public void DeleteEventLog()
        {
            if (EventLog.Exists("SimpleApplication Log"))
            {
                EventLog.DeleteEventSource("SimpleApplication");
                EventLog.Delete("SimpleApplication Log");
               
            }
        }
    }
}

Code for program.cs is as given below :

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SimpleApplication
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("This is my simple application");
            Console.ReadKey();
        }
    }
}


Regards
Sameer Shaik

Tags: Microsoft MCTS exam, Learn, Tutorials, Free C#, Free Videos, Microsoft Dot Net Jobs,Microsoft Dot Net Jobs Interview, Free Training and Preparation, Jobs MCTS specialization, visual studio.net, study guide, sample questions, Exam Prep, Exam Practice Test

How to create Custom Installers part 1



Regards
Sameer Shaik

Tags: Microsoft MCTS exam, Learn, Tutorials, Free C#, Free Videos, Microsoft Dot Net Jobs,Microsoft Dot Net Jobs Interview, Free Training and Preparation, Jobs MCTS specialization, visual studio.net, study guide, sample questions, Exam Prep, Exam Practice Test

Wednesday, September 8, 2010

Reading and Writing Events to/from EventLog

In this post we will explore the following topics:

1. How to view Event Logs?To View Click Here (http://mctsexam70-536tutorials.blogspot.com/2010/09/how-to-view-event-logs.html)
2. How to Register an Event Source?To View Click Here (http://mctsexam70-536tutorials.blogspot.com/2010/09/how-to-register-event-source.html)
3. How to Log Events? To View Click Here (http://mctsexam70-536tutorials.blogspot.com/2010/09/how-to-log-events.html)
4. How to Read Events?(http://mctsexam70-536tutorials.blogspot.com/2010/09/how-to-read-events.html)

The following is the sample code for the above topics:


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace HelloWorld
{
class Program
{
static void Main(string[] args)
{


if (!EventLog.Exists("My Log"))
{
EventLog.CreateEventSource("Sam Application", "My Log");
}

EventLog mylog = new EventLog("My Log");
mylog.Source = "Sam Application";
mylog.WriteEntry("Could not connect", EventLogEntryType.Error, 1001, 1);

Console.WriteLine("Event log written now trying to read from event log");
Console.ReadKey();
Console.Clear();
foreach (EventLogEntry entry in mylog.Entries)
Console.WriteLine(entry.Message);
Console.WriteLine("Press any key to exit!!!");
Console.ReadKey();

}
}
}

We will see in detail all the three topics in the coming video tutorials which will be posted soon.

Regards
Sameer Shaik

Tags: Microsoft MCTS exam, Learn, Tutorials, Free C#, Free Videos, Microsoft Dot Net Jobs,Microsoft Dot Net Jobs Interview, Free Training and Preparation, Jobs MCTS specialization, visual studio.net, study guide, sample questions, Exam Prep, Exam Practice Test

How to Read Events?



Regards
Sameer Shaik


Tags: Microsoft MCTS exam, Learn, Tutorials, Free C#, Free Videos, Microsoft Dot Net Jobs,Microsoft Dot Net Jobs Interview, Free Training and Preparation, Jobs MCTS specialization, visual studio.net, study guide, sample questions, Exam Prep, Exam Practice Test

How to Log Events?



Regards
Sameer Shaik


Tags: Microsoft MCTS exam, Learn, Tutorials, Free C#, Free Videos, Microsoft Dot Net Jobs,Microsoft Dot Net Jobs Interview, Free Training and Preparation, Jobs MCTS specialization, visual studio.net, study guide, sample questions, Exam Prep, Exam Practice Test

How to Register an Event Source?




Regards
Sameer Shaik


Tags: Microsoft MCTS exam, Learn, Tutorials, Free C#, Free Videos, Microsoft Dot Net Jobs,Microsoft Dot Net Jobs Interview, Free Training and Preparation, Jobs MCTS specialization, visual studio.net, study guide, sample questions, Exam Prep, Exam Practice Test

How to view Event Logs?

Hi,
In the video tutorial i have shown how to view an event log of an application which we created and installed onto our system.Only once the our application is installed onto our system, we can create an event log for our application.





Regards
Sameer Shaik


Tags: Microsoft MCTS exam, Learn, Tutorials, Free C#, Free Videos, Microsoft Dot Net Jobs,Microsoft Dot Net Jobs Interview, Free Training and Preparation, Jobs MCTS specialization, visual studio.net, study guide, sample questions, Exam Prep, Exam Practice Test

Reading and Writing Events to/from EventLog

In this post we will explore the following topics:

1. How to view Event Logs?
2. How to Register an Event Source?
3. How to Log Events?
4. How to Read Events?

The following is the sample code for the above topics:


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace HelloWorld
{
    class Program
    {
        static void Main(string[] args)
        {
          

            if (!EventLog.Exists("My Log"))
            {
                EventLog.CreateEventSource("Sam Application", "My Log");
            }

            EventLog mylog = new EventLog("My Log");
            mylog.Source = "Sam Application";
            mylog.WriteEntry("Could not connect", EventLogEntryType.Error, 1001, 1);

            Console.WriteLine("Event log written now trying to read from event log");
            Console.ReadKey();
            Console.Clear();
            foreach (EventLogEntry entry in mylog.Entries)
                Console.WriteLine(entry.Message);
            Console.WriteLine("Press any key to exit!!!");
            Console.ReadKey();
          
        }
    }
}

We will see in detail all the three topics in the coming video tutorials which will be posted soon.

Regards
Sameer Shaik

Tags: Microsoft MCTS exam, Learn, Tutorials, Free C#, Free Videos, Microsoft Dot Net Jobs,Microsoft Dot Net Jobs Interview, Free Training and Preparation, Jobs MCTS specialization, visual studio.net, study guide, sample questions, Exam Prep, Exam Practice Test

Friday, September 3, 2010

Topic : Regular Expressions

Hi,
Below are the links to all the posts which i have created for topic regular expessions. All the topics are explained in C#.net Examples.

Learning regular expression step by step tutorials: Step 1

Learning regular expression step by step tutorials: Step 2

Learning regular expression step by step tutorials: Step 3

Learning regular expression step by step tutorials: Step 4

Learning regular expression step by step tutorials: Step 5

How to match using Backreferences in regular expressions?

Extract matched data using regular expressions C# example

How to use back references to match the patterns?

How to extract matched data from a source and replace substrings using regular expressions

Hope you find these resourceful.

Regards
Sameer Shaik


Tags: Microsoft MCTS exam, Learn, Tutorials, Free C#, Free Videos, Microsoft Dot Net Jobs,Microsoft Dot Net Jobs Interview, Free Training and Preparation, Jobs MCTS specialization, visual studio.net, study guide, sample questions, Exam Prep, Exam Practice Test

How to match using Backreferences in regular expressions?

This video tutorial will provide you with litlle insight on how to use back references in regular expressions.
If you are new to regular expressions you need to check the previous tutorial posts which will teach you some basics of regular expressions.



Regards
Sameer Shaik

Tags: Microsoft MCTS exam, Learn, Tutorials, Free C#, Free Videos, Microsoft Dot Net Jobs,Microsoft Dot Net Jobs Interview, Free Training and Preparation, Jobs MCTS specialization, visual studio.net, study guide, sample questions, Exam Prep, Exam Practice Test

How to extract matched data from a source and replace substrings using regular expressions

In this tutorial we will detect a specific pattern from given source file and edit the source file automatically with our custom format substring pattern

Video Part - 1



Video Part - 2






using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.IO;
using System.Threading;
using System.Security.Permissions;
using System.Text.RegularExpressions;
namespace Example1
{
    class Program
    {

        static void Main(string[] args)
        {
            string SampleText = CreateString();
            DisplayMatches(SampleText);
            Console.WriteLine("We will now replace the dates with our custom format to the file");
            string ChangedText = ReplaceString(SampleText);
            WriteToFile(ChangedText);
            Console.ReadKey();
           
        }

        static string CreateString()
        {
            FileStream fs = new FileStream(@"C:\My stuff\Work Stuff\Blog\Test\SampleText.txt", FileMode.Open);

            StreamReader sr = new StreamReader(fs);
           
            string s = sr.ReadToEnd();

            sr.Close();
            fs.Close();
            return s;

           

        }


        static void DisplayMatches(string s)
        {
           
            Regex r;
            Match m;
r = new
              
            for (m = r.Match(s); m.Success; m = m.NextMatch())
            {
                Console.WriteLine("Found a date in the source"
                + " "+ m.Result("${day}/${month}/${year}"));
            }
        }

        static string ReplaceString(string s)
        {

         
       
        }

        static void WriteToFile(string s)
        {
            FileStream fs = new FileStream(@"C:\My stuff\Work Stuff\Blog\Test\SampleText.txt", FileMode.Open,FileAccess.Write);
            StreamWriter sw = new StreamWriter(fs);
            sw.Write(s);
            sw.Close();
            fs.Close();
            
        }
      




    }
}

Regards
Sameer Shaik

Tags: Microsoft MCTS exam, Learn, Tutorials, Free C#, Free Videos, Microsoft Dot Net Jobs,Microsoft Dot Net Jobs Interview, Free Training and Preparation, Jobs MCTS specialization, visual studio.net, study guide, sample questions, Exam Prep, Exam Practice Test

Thursday, September 2, 2010

How to use back references to match the patterns?

Hi,
I have provided a sample example of how to retrieve matched data from a text file using backreferences. This tutorial will help us in understanding how to create a regular expression for matching the repeating patterns from a source.I will explain in the video tutorial about how to match repeating letters and how to match repeating words from a given source. We will also see how to construct a regular expression for the above scenarios.After we do that we will see how to extract matched data from the source and use it for our purpose.

Video tutorial part - 1



Video Tutorial Part - 2




using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.IO;
using System.Threading;
using System.Security.Permissions;
using System.Text.RegularExpressions;
namespace Example1
{
    class Program
    {

        static void Main(string[] args)
        {
            string SampleText = CreateString();
            DisplayMatches(SampleText);
            Console.ReadKey();
          
        }

        static string CreateString()
        {
            FileStream fs = new FileStream(@"C:\My stuff\Work Stuff\Blog\Test\SampleText.txt", FileMode.Open);

            StreamReader sr = new StreamReader(fs);
          
            string s = sr.ReadToEnd();

            sr.Close();
            fs.Close();
            return s;

          

        }


        static void DisplayMatches(string s)
        {
          
            Regex r;
            Match m;




      
            for (m = r.Match(s); m.Success; m = m.NextMatch())
            {
                Console.WriteLine("Found repeating words  at "
                + m.Groups[1].Index + " And the macth is " + m.Groups[1].Value);
            }
        }
    




    }
}

Regards
Sameer Shaik

Tags: Microsoft MCTS exam, Learn, Tutorials, Free C#, Free Videos, Microsoft Dot Net Jobs,Microsoft Dot Net Jobs Interview, Free Training and Preparation, Jobs MCTS specialization, visual studio.net, study guide, sample questions, Exam Prep, Exam Practice Test