Install and uninstall windows service from command prompt

Suppose you have created a windows service name “YourServiceName.exe”. Now you want to install or uninstall it from command prompt. To Install Service run the commnad: C:\Windown\Microsoft.Net\framework\v2.0\installUtil.exe  C:\dirctory\YourServeceName.exe     (with location) To Uninstall Service run the command: C:\Windown\Microsoft.Net\v2.0\installUtil.exe /u C:\dirctory\YourServeceName.exe         (with location)

A Simple Demonstration with ASP.net GridView

GridView is a powerful control of ASP.net. Here I tried to demonstrate gridview with a simple project. I have stored employee information then displayed it in gridview and insert, update and delete employee information. Step 1: Create a table name hrm_employee and insert some sample data in it. –Create Table : hrm_employee— CREATE TABLE hrm_employee

Read More

Open Close Principle with C#

Open Close Principle is an Object Oriented Design principle. It is first introduced by Betrand Meyer in 1988. He says “Software entities (Class, module, function etc.) should be open for extension, but closed for modification”. An entity is “Open for extension” means that its behavior can be extended to accommodate new demand. The entity is

Read More

Singleton Design Pattern with C#

Design Pattern Design pattern is a solution of known problems. These are strategies of solving commonly occurring problems. A design pattern is not a finish design. It is like a template to solve a problem. Singleton Design Pattern Singleton is a software design pattern. It is restrict to create object more than once. This is

Read More

Padding character with string

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Padding { class Program { static void Main(string[] args) { string str = “This is a text”; char padChar = ‘.’; Console.WriteLine(str.PadLeft(25, padChar)); Console.WriteLine(str.PadLeft(2, padChar)); Console.WriteLine(str.PadRight(25, padChar)); Console.WriteLine(str.PadRight(2, padChar)); str = “I am Mahedee hasan. Software Architect, Leadsoft Bangladesh Ltd”; Console.WriteLine((str.PadRight(25, padChar))); Console.WriteLine((str.PadRight(25,padChar)).Substring(0,24)+”…”); Console.ReadKey();

Read More

Iterator Design Pattern with C#

Iterator pattern is a design pattern which is used to traverse aggregate object often called container and access container’s object without exposing it’s underlying representation. Iterator pattern decoupled algorithm from aggregate object or container. In some cases, algorithms are container specific. We often use collection in C# and then we traverse the collection without knowing

Read More

How to send email in ASP.net

ou have to configure SMTP server before sending email from your server. Hope you already know how to configure smtp server. Here is the simple code segment for sending email against a button click. protected void btnSendMail_Click(object sender, EventArgs e) { SmtpClient smtpClient = new SmtpClient(); MailAddress fromAddress = new MailAddress(“mahedee_hasan@leads-bd.com”); //Sender email address MailMessage

Read More

Calculate file checksum using c#

Calculate file checksum using c# using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Security.Cryptography; using System.Text; using System.Threading.Tasks; namespace CheckSumTest { class Program { static void Main(string[] args) { string filePath = @”G:\Mahedee_Share\Created\23062014-1\FileDeployManager\FileDeployManager\Form1.cs”; string checksumMd5 = GetFileChecksum(filePath, Algorithms.MD5); string checksumSha1 = GetFileChecksum(filePath, Algorithms.SHA1); string checksumSha256 = GetFileChecksum(filePath, Algorithms.SHA256); string checksumSha384 = GetFileChecksum(filePath, Algorithms.SHA384); string

Read More

Strategy Design Pattern with C#

Strategy design pattern is a behavioral design pattern. It is a particular software design pattern where algorithms are selected at runtime. According to the book of Design Pattern (Gang of Four) – “Define a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithm vary independently from clients that use it.

Read More

Abstract Factory Pattern with C#

Abstract factory pattern is a creational design pattern. Creational design pattern is deals with object creation mechanism. Object creation mechanism is changed on the basis of problem. Abstract factory pattern provides an interface to create families of related or dependent objects without specifying their concrete class. It is identified on the basis of problem complexity.

Read More

Factory Design Pattern with C#

Factory design pattern implements the concept of real world factories. Factory pattern is a creational design pattern. It deals with creating object without specifying exact class. In general, actors of factory patterns are a client, a factory and a product. Client is an object that requires another object for some purposes. Rather than creating the

Read More

How to copy folder with content with C#

using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace CopyFolder { class Program { static void Main(string[] args) { string sourcePath = @”G:\Mahedee_Share\Created”; string destPath = @”G:\Mahedee_Share\Development”; CopyFolder(sourcePath,destPath); } private static void CopyFolder(string sourcePath, string destinationPath) { try { //Now Create all of the directories foreach (string dirPath in Directory.GetDirectories(sourcePath, “*”,

Read More

How to check Palindrome word using C#

Palindrome word can be read in both direction. Suppose “level” can be read in both direction, so it is palindrome word. To check palindrome word you can try like following code using C#. class Program { public static bool IsPalindrome(string word) { int minLength = 0; int maxLength = word.Length – 1; while (true) {

Read More