C# simple class to convert a URL into acceptable windows file name

Hi, i was working on a project that takes screen-shots of web pages that are loaded in to Internet Explorer browser.As per the clients requirement, I need to save the screen-shot of a web page using the later ‘s URL.
I searched the web to find some help, but found nothing that matches my criteria, then i decided it do it my own way, write your own class file for converting a URL into an acceptable windows filename.
here is the code that will change a URL into a filename.

To use the code, copy this code into your project, and declare an object of the class and call the ConvertToWindowsFileName method.

C# code to extract Email

In this post, i am going to provide the readers with sample code to Extract Email addresses from a given string and store them into a list.I will give the code as Method, so that you can easily import it into your application.This code can be easily used to extract Email Id’s from a webpage, just pass the HTML of the web page as the textToScrape to the method.

Changing array length at runtime in C#.net

Dealing with arrays is a part of life for coders as they are almost every where in the code, so i thought that it would be the best topic to start my blog that deals with programming related topics.

Array Declaration in C#.net

as we now know how to intialise an array, now lets store some values into it

Storing values in array

The above code stores the values 1  to 10 in the array “Myarray”.

Ok enough of the basics, now lets go straight to Arrays with dynamic length

Creating arrays with dynamic length

  1. To start with declare an array of your choice with zero length (or any length), i am using an int array
  2. now when you are about to enter the values into increase the length of the array using Array.Resize method
  3. The syntax of the Array.Resize method is
  4. Array.Resize(ref Array_2_Resize, Length)
  5. Now pass the value to the Array as Myarray[Myarray.Length-1] = value;

Example: The following example demonstartes how to Increase the length of an array at runtime

One important thing to note here is that the Array.Resize wont actually resize the array, it will actually create a new array with the specified size and copies all the elements from the old array to the newly created array and then replaces the old array with the new array.

To read more on this, read the MSDN article