Logoff the Computer using C#
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Diagnostics; namespace Dotneter.com { class Program { static void Main(string[] args) {...
View ArticleHibernate the Computer using C#
For hibernate you can just call Application.SetSuspendState. using System; using System.Collections.Generic; using System.ComponentModel; using System.Text; using System.Windows.Forms; namespace...
View ArticleGet system uptime using C#
string uptime = String.Empty; uptime += (Environment.TickCount / 86400000).ToString() + " days, "; uptime += (Environment.TickCount / 3600000 % 24) + " hours, "; uptime...
View ArticleCheck if the current user is Administrator using C#
using System.Security.Principal; private bool isAdministrator() { WindowsIdentity windowsIdentity = WindowsIdentity.GetCurrent(); WindowsPrincipal windowsPrincipal = new...
View ArticleGet the Computer Name using C#
System.Windows.Forms.SystemInformation.ComputerName.ToString(); or System.Environment.MachineName;
View ArticleGet current username in Windows using C#
System.Security.Principal.WindowsIdentity.GetCurrent().Name;
View ArticleGet Windows Folder using C#
Environment.GetEnvironmentVariable("SystemRoot"); or Environment.GetEnvironmentVariable("windir");
View ArticleCopying Rows from One Table to Another – C#
Use Clone method to copy the table structure (Schema) DataTable dtProductCopy = new DataTable(); dtProductCopy = dtProduct.Clone(); Use the ImportRow method to copy from...
View ArticleGet Connection String from app.config, web.config
Get connection string by connection’s name string conn = ConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ConnectionString; or string conn =...
View ArticleHow to add icon to website
To add an icon for the website you just add the following code to the head element: <LINK REL="SHORTCUT ICON" HREF="http://www.domain.com/iconname.ico"> CODE Example: <HEAD>...
View Article