How to create Vista Gadget

We can create a Vista Sidebar Gadget by easily. Just follow the below steps then you are the owner of a sidebar gadget.

Step 1:

Create the following html file with the name of “HelloWorld.html”.

Step 2:

Create the following xml file with the name of “Gadget.xml”.

Step 3:

Create a folder called Helloworld.Gadget

Step 4:

1.Simply copy”%userprofile%\AppData\Local\Microsoft\Windows Sidebar\Gadgets” and paste in Windows explorer address bar.
2. When you get to that folder Copy and Paste the “HelloWorld.Gadget” folder there.

Step 5:

Add the gadget to your Sidebar and your done !

For more visit here …


How to get duration of an audio file in c# ?

We can get the duration of an audio or video file by using the “Shell32” namespace in Visual Studio Dot Net. For that we need to add the reference of “Interop.Shell32.dll” in to our project. And follow the given method in below. By calling the following method with the parameter of full path of file name which might be an audio file or video file we can get the duration of that file.

private string GetDuration(string FileFullPath)
string duration = "";
string fName = FileFullPath.Substring(FileFullPath.LastIndexOf("\\") + 1);
string filePath = FileFullPath.Substring(0, FileFullPath.LastIndexOf("\\"));
Shell32.Shell shell = new Shell32.ShellClass();
Shell32.Folder folder = shell.NameSpace(filePath);
Shell32.FolderItem folderItem = folder.ParseName(fName);
if (folderItem != null)
duration = folder.GetDetailsOf(folderItem, 21);
folderItem = null;
folder = null;
shell = null;
return duration;

Hence we can get the duration of given file.


Find Age from given DateOfBirth using C#

Hi all,

Just copy the following method in your class and call it with the parameters of date of birth and current date in DateTime format.

public string FindAge(DateTime dob, DateTime currentDate)
int years = currentDate.Year - dob.Year;
int months = 0;
int days = 0;
if(currentDate < dob.AddYears(Years) && Years != 0)
dob = dob.AddYears(years);
if (dob.Year == currentDate.Year)
months = currentDate.Month - dob.Month;
months = (12 - dob.Month) + currentDate.Month;
if(currentDate < dob.AddMonths(months) && months != 0)
dob = dob.AddMonths(months);
days = (currentDate - dob).Days;
return years + " years " + months + " months " + days + " days";

Copy the above code in your class...and call the method..enjoy... ;)


Code for moving the form by mouse clicking.

Hi Viewers,

Here by I am trying to give you a sample code for moving the win form by clicking the mouse.

Just use the following code and test it.

using System.Runtime.InteropServices;

public const int WM_NCLBUTTONDOWN = 0xA1;

public const int HT_CAPTION = 0x2;

public static extern int SendMessage(IntPtr hWnd,int Msg, int wParam, int lParam);

public static extern bool ReleaseCapture();

private void Form1_MouseDown(object sender, MouseEventArgs e)
if (e.Button == MouseButtons.Left)

Now you can implement the above code in your application and test it. Working fine for me


Add prerequisites of dotnet framework in visual studio setup project

When we developing an application using any platform we should prepare our application to be deployed properly. Specially for dotnet, the prerequisites of dotnet framework is must. So here by I am explaining how to add framework to be installed before our application installation process.

After developing our .Net application we need to create a setup project. Just follow the steps mentioned in below.

- Go to File menu, select Add New Project and then select Setup And Deployment in under “Other Project Types”.

- Give a name to your project as your wish.

- Then select your setup project solution and add Primary output of your developed project. You just need to right click your setup project in solution explorer, click add --> Project Output --> select your project.

- Then add custom action by right clicking setup project --> view --> Custom Actions --> right click Custom Actions --> Add Custom Actions.

- Now we are going to add the prerequisites for your setup project.

- Select your setup project right click and go to properties then click the Prerequisites button.

- Now select .Net Framework 2.0 tick box after selecting the “Create setup program to install prerequisite components”.

- Then specify the install location for prerequisites by selecting the option box.

- Here I am selecting the second one “Download prerequisites from the same location as my application”.

- Click ok and apply then ok.

- Now build your setup project, the dotnet framework will be added in your debug folder.

That's it...