Search This Blog

Wednesday, September 10, 2014

Delete directory C#

C# > Files > Directory > Delete

Deletes the specified directory.

Example

Deletes the specified directory and any subdirectories and 

files in the directory.


System.IO.Directory.Delete(@"c:\Temp\", true);







Friday, August 29, 2014

How to get if is Runtime or Design Mode VB.net

VB.NET > Control > DesignMode

DesignMode returns true is a control is being used in the context of a designer. 

Example:

If Me.DesignMode Then
      Return
End If





Tuesday, August 12, 2014

Typeof C# example

C# > Keywords > typeof

Obtains the System.Type object for a type.


Example:



Type type = typeof(T);







Wednesday, July 30, 2014

SerialPort Class Example

C# > IO  > Ports > SerialPort

SerialPort controls a serial port file resource. 

Example

1. Gets all serial port names for the current computer.

List<String> serialPorts = new List<String>();
foreach (String portName in System.IO.Ports.SerialPort.GetPortNames())
{
  serialPorts.Add(portName);

}





System.IO.Ports Namespace C#

C# > IO  > Ports

System.IO.Ports contains classes for controlling serial port.






Thursday, July 24, 2014

CAST SQL Server Example

SQL Server > Built-in Functions > CAST

CAST converts an expression of one data type to another.


CAST ( expression AS data_type )

Examples







Wednesday, July 16, 2014

ROWCOUNT SQL Server Example

SQL Server > Built-In Functions > @@ROWCOUNT

Returns the number of rows affected by the last statement.

Example:

UPDATE Person
SET Age = 31
WHERE Id = 1
IF @@ROWCOUNT = 0
    PRINT 'No rows were updated';