Click here to Skip to main content
15,886,518 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I need a desktop program to read .txt file and make every word in a separate line
Posted
Comments
Varun Sareen 9-Oct-12 6:41am    
you need it??? dear friend we are not here to do your homework or to do your task. We are here to help you resolve your problem. First attempt yourself then if you face problem then let us know.

Regards

Varun

Look at:
File.ReadAllText[^]
String.Split[^]
By using a combination of the two, you can achieve your aim.
 
Share this answer
 
Comments
MostafaAttia 7-Nov-12 3:17am    
Thank you for help
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 SelectDictionary
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog()==DialogResult.OK)
            {
                StreamReader Reader = new StreamReader(openFileDialog1.OpenFile());
              
                txteditor.Text= File.ReadAllText(openFileDialog1.FileName);

                char[] arr = txteditor.Text.ToCharArray();
                System.Text.StringBuilder stt = new StringBuilder();
                foreach (char c in arr)
                {

                    if (c != ' ')
                        stt.Append(c);
                    if (c == ' ')
                    {
                        stt.Append(System.Environment.NewLine);
                    }
                }
                txteditor.Text = stt.ToString();
            }
        }
       
        private void btnSave_Click(object sender, EventArgs e)
        {

            if (saveFileDialog1.ShowDialog()==DialogResult.OK)
               
            {
              
                System.IO.File.WriteAllText(saveFileDialog1.FileName,txteditor.Text) ;
                
            }
        }

    }
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900