File Handling using C#

 
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Collections;
namespace MySpace
{
    class FileHandling
    {
        static void Main(string[] args)
        {
            //string str = "\"Pacific/Tongatapu\">(GMT+13:00) Nuku’alofa";
            //Console.WriteLine(str.ToString());
            //Console.WriteLine(str.Substring(0, str.IndexOf(‘>’)));
            StreamReader objReader = new StreamReader("c:\\timeZone.txt");
            string sLine = "";
            ArrayList arrText = new ArrayList();
            while (sLine != null)
            {
                sLine = objReader.ReadLine();
                if (sLine != null)
                {
                    sLine = sLine.Substring(0, sLine.IndexOf(‘>’));
                    arrText.Add(sLine);
                }
            }
            objReader.Close();
            StreamWriter sw = new StreamWriter("C:\\timeZone1.txt", true, Encoding.ASCII);
            foreach (string sOutput in arrText)
            {
                sw.WriteLine(sOutput);
                Console.WriteLine(sOutput);
            }
            sw.Close();
        }
    }
}
Advertisements
This entry was posted in Information Technology. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s