Encrypt a file in c#
static void EncryptFile(string sInputFilename, string sOutputFilename, string sKey) { FileStream fsInput = new FileStream(sInputFilename, FileMode.Open, FileAccess.Read); FileStream fsEncrypted = new...
View ArticleDecrypt a file in C#
static void DecryptFile(string sInputFilename, string sOutputFilename, string sKey) { DESCryptoServiceProvider DES = new DESCryptoServiceProvider(); //A 64 bit key and IV is required for this provider....
View ArticleList of MIME types
List of MIME types / Internet Media Types Name MIME Type / Internet Media Type File Extension More Details 3D Crossword Plugin application/vnd.hzn-3d-crossword .x3d IANA: 3D Crossword Plugin 3GP...
View ArticleAdd and Clear Items in a ListBox Control
This example adds the contents of a Windows Forms TextBox control to a ListBox control when you click button1, and clears the contents when you click button2. private void button1_Click(object sender,...
View ArticleDate Time Format in C#
// create date time 2008-03-09 16:05:07.123 DateTime dt = new DateTime(2008, 3, 9, 16, 5, 7, 123); String.Format(“{0:y yy yyy yyyy}”, dt); // “8 08 008 2008″ year String.Format(“{0:M MM MMM MMMM}”,...
View ArticleCalculate difference between two dates (number of days)
one calculate the number of days between two dates in C# DateTime xmas = new DateTime(2009, 12, 25); double daysUntilChristmas = xmas.Subtract(DateTime.Today).TotalDays; Related posts: Calculate Number...
View Articlescript to create database in ms sql server
USE [master] GO /****** Object: Database [DATABASENAME] Script Date: 03/26/2013 10:53:46 ******/ CREATE DATABASE [DATABASENAME] ON PRIMARY ( NAME = N’DATABASENAME’, FILENAME = N’C:\Program...
View ArticleMD5 Message-Digest Algorithm
The MD5 Message-Digest Algorithm is a widely used Cryptographic Hash Function that produces a 128bit (16-byte) hash value. Specified in RFC 1321,, MD5 has been employed in a wide variety of security...
View ArticleArrays in C#
Arrays works as collections of items, for instance strings. You can use them to gather items in a single group, and perform various operations on them, e.g. sorting.This fact alone makes it important...
View ArticleCommunication with serial post
Steps to get data from serial ports 1. Create a new windows forms application 2. On the default form, form 1, from the toolbox, drag a ‘serial port’ onto the form 3. You will see the serial port in the...
View Article