Working With Files in C#

In this tutorial we will be working with files. How to create a file, edit it, rename it, make a copy of an existing file or move it.

First thing you should do is to reference the System.IO namespace.

All the classes that will help you handle files are located in this namespace.

using System.IO;

How to create a file and edit it?

You can create a file like this:

string path = @"C:\test.txt";

This will create a file “test.txt” in Continue reading

Image Viewer application using C#

A detailed tutorial about creating an Image Viewer or Picture Viewer application in C#. This application also converts Images from one type to another.

Following are the features of this application:

  • Open / Save images.
  • Convert images.
  • Rotate Images.
  • All popular image formats are supported.

Let’s get started! Continue reading

C# – Check if connected to internet

I was working on an application which checked for updates. I used WebRequest/WebResponse for checking updates. It showed a continuous Progressbar while checking for updates. But there was a problem. It worked properly when you were connected to internet but it  just showed the progressbar all the time if not connected.

The solution for that was to check for internet connection before checking for updates. If connected then check for updates otherwise show an error.

Checking for the state of internet connection is very simple. Let’s get started.

Continue reading

C# – Autocomplete Textbox

There are times when you’ll need an autocomplete textbox. Autocomplete textbox makes the user’s life easier. It shows suggestions as the user types. In case of a web browser, if you type “goo” it will automatically show all the suggestions starting with or containing “goo” like “Google, Goofy” etc. It really helps both you or your users when hunting for something. Of course, it seems difficult to set up, but the reality is very different. So whether they’re typing in “find O2 UK BROADBAND” or you’re hunting for “that holiday video”, then your users are likely to find it a lot faster. Enough talk! Lets get on with it.

Fortunately, textbox has a built-in autocomplete feature! We don’t have to do any coding.

You can either set it up from the Designer (if you are using Visual Studio or #Develop) or do it via code. It is simple both ways. Lets do it!
Continue reading