Creating mutually exclusive code block C#

Sometimes, we may need to act on some information(object) which is critical for the application and we need to make sure that the information contained by that object is consistent. The way to keep the information in the object consistent is to avoid the access of that object by more than one thread or program. …

Read More

Fetching URL contents into a string using HttpWebRequest

You can use the below class for fetching the contents of any HTTP URL using the HTTP GET method. This makes use the webrequest classes of .NET class library. public static class GetUrl { public static string FetchURL(string url) { const int bufSizeMax = 65536; // max read buffer size conserves memory const int bufSizeMin …

Read More

add/update windows users – windows user management

Sometimes, we may need to add/update the windows user management functionality in our windows application or windows service. In such cases, we can just use the ‘net user’ functionality of the windows operating system. Refer the below command to perform user operations. NET USER [username [password | *] [options]] [/ username {password | *} /ADD …

Read More