Posts By Category

Posts By Date

Resources:

C# Books
ASP.NET Books DotNet4All








If you like to support this site, feel free to make a donation to support improvements.

Thank you!

Monetize Your Blog

Use Intermittent Sleeping (small increments) instead of one long Thread.Sleep for a quicker, more responsive multi-threaded application

We all had to use Thread.Sleep at one point or another to wait on an event to happen, or to satisfy a configuration setting during cyclic calculations or a processing. But is your worker thread sleeping too much? Does it feel sometimes that your code sleeps in the wrong time

Continued...

A list of all the free utilities & user controls in C# & ASP.NET on www.mycsharpcorner.com ...

Here is a list of all the free utlities & user controls developed and published on http://www.mycsharpcorner.com . More will be coming soon, but for now, here is a quick list:

Social Links User Control in ASP.NET - Read the related article

Continued...

How I handled 301 redirects to avoid duplicates in my SE ratings

If you have done SEO work, you know that Search Engines would penalize my site if both http://www.mycsharpcorner.com and http://mycsharpcorner.com/ requests returned a 200 OK code in the HTTP header. Why? Because from a Search Engine's spider point of view, there are 2 sites, one with the www prefix, and one without it, yet in reality they the same site. So what’s wrong if the Search Engine thinks

Continued...

How to calculate one column from another in Excel

Well, this is not a programming tip; it is more of a general Excel tip from a recent assignment I had for one of my clients. I had an Excel document with two columns; one needed be calculated from the other based on a percentage formula, so:

SalePriceColumn=OriginalPriceColumn + 15% extra

Continued...

A free user control to hold the social links icons in ASP.NET

Do you like the social links bar on top of this article? Do you hate it? In today's internet blog, you almost never miss seeing a "Digg It", a "Kick it", a "Ridd It" a Furl it, burl it...or squirrel it... link or icon at the end of each article you read in someone's blog. Well, regardless of the opinions people might have about this phenomenon, if you are an ASP.NET programmer like me, your concern would probably be over how to construct the "social-butterfly" user control, rather than

Continued...

Real Time Traffic Tracker for your site

It's been three weeks since I started this project, and I've been curious to see how the site is being used, and how many people are visiting... what are they reading...etc. So I started a small little project on the side, called the Traffic Tracker.

Continued...

Using StreamReader & StreamWriter to insert a text at a given line number

System.IO.StreamWriter allows you to write text to a file easily if you are creating the file and know the order of the lines. However, what if you are trying to edit a file? For example, you need to insert a text at a specified line number in an existing text file. Say you have a text file that contains: Continued...


Programmatically send emails using Google mail server and System.Net.Mail.SmtpClient

Did you know you can use your gmail mail server to send and receive emails programmatically for free?

Continued...

How to write C# code to check if Google’s bot crawled your ASP.NET site

If you are monetizing your site with AdSense, one important piece of traffic you want to monitor, is when Google spider visits your site to crawl it. Or maybe you want to know if the Google robot ever comes to visit or not, and if it does, when, and how often does it crawl your site? Doing this in ASP.NET is very

Continued...

How to close another process's main window from a C# App without invoking Native Win32 code

Back in the good (or bad :) ) days of Win32 programming, there was a nice little function named FindWindow. It enabled you to find any window belonging to any process on your system

These days are gone with C# .NET, well... not quite!

If you have been looking for an alternative to FindWindow, Read along. There are two alternatives, the first involves invoking FindWindow directly from the Native Win32 DLL API, but that takes us back to the old days.

Continued...

System.Windows.Forms.Timer does not work for Console Applications because you need an event loop, so you need to use System.Threading to implement your own timer with an event loop, here is how...

In Console Applications, you don't have an event message loop like in a Windows Application project, hence, so you can't use the System.Windows.Forms.Timer object since it depends on Windows Message loop to fire its tick events.

Continued...

Fun with C# Timers… Flash a Windows Control to draw attention to it's invalid data

 Download

One common Windows Application development task is to validate a TextBox or a Windows Control against a certain value, or whether the user has entered a value at all before hitting the submit/Ok button, then display some kind of an error.

Continued...

You can spawn the regedit.exe command utility to simply mimic it's behavior in your C# application, here is how...

One of my clients needed to run a script on a user machine every time the user logged in. The script would import some registry keys and settings that customize certain parts in Windows for their client.

My task was to write the script. Well, my first thought was to write a text parser for their .reg file, then using the .NET Registry classes to import all the keys into the registry one by one.

Continued...

Track your visitors IP & Host Info, but make sure to catch any exceptions

In my previous article, How to track visitors to your site in ASP.NET & C#, I discussed how you can log the Host Info for each page visitor on your site using Dns.GetHostByAddress function.

One thing I did not stress out was the need to catch all exceptions from that method call. There are cases when this call:

Continued...

Code to log the IP address & DNS name for visitors to each page

Once you have published a site in ASP.NET, you'd like to know who are your visitors. One way is to check your event log on the host server. Another option is to write your own code. You'd basically like to log the IP address, and DNS name for the visitor, and it would be nice to know which page they are visiting.

To log the ip address using ASP.NET, you can call:

Continued...

How to parse a webpage in C#? Simple text parsing in C# using GetStringInBetween, GetStringBetween

One common requirement especially when doing screen scrapping is to find strings contained between html tags, or other strings. Regular Expressions provide a powerful way to do so, but are initially intimidating for a beginner programmer. Here is an alternative solution to finding a string between two other strings that uses simple string manipulation in C#, without Regular Expressions:

Usage:

Continued...

How to parse a webpage in C#? Text Parsing in C#

We all know how to remove/replace a string in C#, for example:

string myString = "Yousef (programmer) likes to write in C#";

To remove "(programmer)", we can write:

myString = myString.Replace("(programmer)", "");

Continued...

Code to log the IP address & DNS name for visitors to each page

Once you have published a site in ASP.NET, you'd like to know who are your visitors. One way is to check your event log on the host server. Another option is to write your own code. You'd basically like to log the IP address, and DNS name for the visitor, and it would be nice to know which page they are visiting.

To log the ip address using ASP.NET, you can call:

Request.ServerVariables["HTTP_X_FORWARDED_FOR"]

Continued...

Monitor processes as they start and end on your computer, good for catching viruses, spyware, or just simple system diagnoses

Process Logger monitors processes as they start and end on your computer and logs them out. It's very useful if you are suspecting some spy ware or even viruses being on your computer, and want to closely monitor what process starts and stops as soon as it happens. It can also help

Continued...

utilizing GetProcesses in .NET to log start and end times for currenlty running processes on yoru machine

Here is a quick C# script to log the start and end times of running processes on your machine.

The idea is query the currently running processes every x number of seconds utilizing the Process.GetProcesses function in .NET, while maintaining a book for currently running processes each cycle, then if a new process appears (or disappears), you log the result as start and end respectively.

Here is how to get currently running processes on your machine using C#:

Continued...

Use .NET Timers to setup a Clock user control on a Windows Form in C#

Making your own Clock control to display on your Windows Form to display and update the current time up to the second is an easy deal using C# Timers.

Creating The Clock User Control Step By Step

Here is one way to do it:

Continued...

Copyright © 2007 Yousef Mannaa. All material on this site is copyrighted.
Do not publish or reproduce any of this material without written permission from the Author