Category: C#

How to use php mcrypt_encrypt with C# chilkat decrypt

I recently came across a situation where I needed to encrypt a string in PHP using blowfish and then decrypt later using C# (please note I use the excellent chilkat .net component for decryption). The PHP encryption bit is below (make sure you use PHP… more »

Load an html page and print it using c#

To use the this code you need to right click on your tool box and click to add the com component called Microsoft web browser first! private void button(object sender, EventArgs e) { //when the button is pressed the page is loaded… more »

Get selected Cell content from datagridview in C#

To get the content of the selected text simply add the following line in your single click event: datagridview1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString()); or if you want a specific cell to always be selected simply add the index of that… more »

C# connect to SQL express and retrieve a set of data

try { SqlDataReader thisReader; SqlConnection thisConnection = new SqlConnection("Data Source=SERVERNAME\SQLEXPRESS;Initial Catalog=yourdatabase;Integrated Security=True;");… more »

Convert String to a float variable using C#

float myfloat = float)System.Convert.ToSingle("99.16"); more »

Read text file and retun it as one string in C#

public string readTextFile(string filename){ //loads a text file and returns the string System.IO.StreamReader file = new System.IO.StreamReader(@"\"+filename); string test = file.ReadToEnd(); return te… more »

Save a text file in C#

using System.Text; using System.IO; public void saveTetFile(String filename, String filecontent) { //saves a text file TextWriter tw = new StreamWriter(filename); // write a line of text to the… more »