Tuesday, December 21, 2010

How to create a GUID in C#

GUID (Globally unique identifier) is a 128-bit integer that can be used to uniquely identify something.
You may store users or products in your database and you want somehow uniquely identify each row in the database.
A common approach is to create a autoincrementing integer, another way would be to create a GUID for your products.
The GUID method can be found in the System namespace. The GUID method System.Guid.NewGuid() initializes a new instance of the GUID class.


Response.Write(@"
System.Guid.NewGuid().ToString() = " + System.Guid.NewGuid().ToString());


Response.Write(@"
System.Guid.NewGuid().ToString(""N"") = " + System.Guid.NewGuid().ToString("N"));

Response.Write(@"
System.Guid.NewGuid().ToString(""D"") = " + System.Guid.NewGuid().ToString("D"));

Response.Write(@"
System.Guid.NewGuid().ToString(""B"") = " + System.Guid.NewGuid().ToString("B"));

Response.Write(@"
System.Guid.NewGuid().ToString(""P"") = " + System.Guid.NewGuid().ToString("P"));

Monday, December 20, 2010

The connection [ip] requires the use of the SonicWALL Adapter, error

If you get the error when using SonicWALL VPN:
The connection "ip address" requires the use of the SonicWALL Adapter, however this adapter can not be found. Itmay have been disabled or uninstalled. Please check your network configuration."

This is What you need to do in order to fix it:
  •  Control Panel >> Network Connections
  • Right click on SonicWALL Virtual Adapter
  • Select Enable
  • Try to connect again, you should be able to connect now

Friday, December 17, 2010

Programmatically opening a file in its native program

OpenFileDialog ofd = new OpenFileDialog();


if (ofd.ShowDialog() == DialogResult.OK)

                  System.Diagnostics.Process.Start(ofd.FileName);

Thursday, December 16, 2010

How to disable Utility Manager (Windows Key + U)

Pressing the Windows key with U starts the Utility Manager, which provides a number of useful aids (e.g., the Narrator, magnifier, on-screen keyboard) for people who have poor vision. 


To disable this shortcut, perform one of the following options: 


Option 1
1.Start the Microsoft Management Console (MMC) Services snap-in (Start, Programs, Administrative Tools, Services). 
2.Right-click Utility Manager, and select Properties. 
3.Set the Start-up type to Disabled, and click Apply. Then click OK. 


Option 2
Under C:\Windows\System32 you can rename utilman.exe to disable it.

Option 3
If renaming the utility doesn't work, try deleting the util & replacing it with a null file, [cmd window]:
Del utilman.exe 
COPY nul utilman.exe 
Attr utilman.exe +R