C#.zip

How to send binary data through C# CGI app?

997

Following example implemented binary data downloading. If you are using Apache and wanna test it just put the EXE in the cgi-bin folder under Apache's directory.Also note that the parameters are static just for this example.

How To Print Text In C#

456

If you want to use MultipadPrintDocument in your own code,it's best to rename the class and its constructor to something more appropriate.Then add a variable of type XXXPrintDocument to your form and implement the menu items as follows: .

How to restrict a program to a single instance

731

In the program's Main method,call ProcessUtils.ThisProcessIsAlreadyRunning() to determine if another instance of the program is already running.ThisProcessIsAlreadyRunning attempts to create a Mutex object with the same name as the program (Application.Pro...

To load image from file

454

The `Image.FromFile` method in C# is used to load an image from a specified file path into an `Image` object.It takes a string argument representing the full path to the image file and returns a new `Image` object containing the loaded image data.This meth...

How to resize and save PNG or Jpeg Image file ?

635

The PictureBox control in C# is a visual element that allows you to display images within your application's user interface.It's a versatile tool for displaying images,icons,graphics,and other visual content,and it can be easily manipulated using propertie...

How to speed up access to the RichTextBox Lines property

832

Using a foreach loop will be substantially faster than a for loop when accessing the items in a RichTextBox's Lines property. For example, the following code loads a RichTextBox with 1000 lines of text and accesses each line from the Lines property. On a 3...

How To Check If Your Printer Is Connected Using C#

1,027

This code will test whether a printer is connected to your system or not. It works with USB and network printers (haven't tested LPT printers yet). Some printers (like my HP DeskJet 930c) is detected online even though I press the OFF b...

How to get process id in C# like windows task manager ?

870

Following is simple example to get process name and add process name to listbox control.As you can see below, you can get working process by Process control. But most of the properties are supported on windows platform. If you want to access the similar pr...

How to convert bitmap image to jpeg image ?

357

C# provides easy interface to convert image.Following is the simple example.using System.Drawing.Imaging;...Image image = Image.FromFile("test.bmp");image.Save("test.jpg", ImageFormat.Jpeg);Above is PNG to jpeg. You can convert Jpeg to PNG as following.usi...

How to convert text string to integer ?

612

C# provides an excellerent static instance can convert various types. You can easily get the wanted reult by Convert Class. Because It's a static instance, you don't need to declare instance.Following is the example to example to convert from text string t...

How to convert integer to text string ?

700

C# provides an excellerent static instance can convert various types. You can easily get the wanted reult by Convert Class. Because It's a static instance, you don't need to declare instance.Following is the example to example to convert from integer to te...

Graphics in C# - Irregular Forms

912

Quite frankly, I think this topic is a lot of fun...the thought of making an app look completely different from the usual rectangular-formed layout really appeals to me.Drawing an irregular form, like drawing anything, requires four things : a surface, a s...

Extracting the Country from IP Address

470

Notes: If you want to run this sample,you should copy the Ip address to driver c:. Using the codePart 1.using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows....

Calling Your Main Thread From A Worker Thread In C#

550

There are many cases where it is necessary to let your main application know that a thread has completed. Your main application could spawn some threads to do background work and then when the threads have completed their work they could return the results...

How To Read And Write A Cookie

364

A post on aspngbeta about readingwriting a cookie in C# / / To setHttpCookie cookie;String UserID = "foo";cookie = new HttpCookie("UserID");cookie.Values.Add("UserID",UserID);Response.Cookies.Add(cookie); / / To readHttpCookie cookie;cookie = Request.Coo...

Using C# With Cookies

628

A code snippet posted on aspcs about accessing and writing cookies using C#. / * Read shopper id from client cookie * / public static bool GetCurrentShopperId(ref string id,System.Web.HttpRequest request){try{HttpCookie cookie = request.Cookies["iparts_pa"...

Address Book

578

Saves an address book database as a cookie on the user's computer. The author explains that although the actual example may not be particularly useful, the underlying code could be very beneficial for use in other projects.