Line number

Unknown | 5:19 AM |

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace WindowsFormsApplication1
{
    public partial class linenumber : Form
    {
        public linenumber()
        {
            InitializeComponent();
        }

        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            openFileDialog1.Filter = "Text file(*.txt)|*.txt";
            string filename;
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                filename = openFileDialog1.FileName;
                int dr = 0;
                FileStream f = new FileStream(filename, FileMode.Open);
                StreamReader sr = new StreamReader(f);
                string line;
                StreamWriter sw = File.CreateText(@"E:\numbered.txt");
                while ((line = sr.ReadLine()) != null)
                {
                    dr++;
                    sw.WriteLine("{0}{1}", dr, line);
                }
                sw.Close();
                f.Close();
                MessageBox.Show("File numbered successfully");
                System.Diagnostics.Process.Start(@"E:\numbered.txt");

            }
        }
    }
}

Category:

About http://dotnetvisual.blogspot.in/:
DOT NET TO ASP.NET is a web application framework marketed by Microsoft that programmers can use to build dynamic web sites, web applications and web services. It is part of Microsoft's .NET platform and is the successor to Microsoft's Active Server Pages (ASP) technology. ASP.NET is built on the Common Language Runtime, allowing programmers to write ASP.NET code using any Microsoft .NET language. create an application very easily ....