Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.IO;
- using System.Windows.Forms;
- namespace ProbaForms
- {
- static class Program
- {
- [STAThread]
- static void Main(string[] args)
- {
- OpenFileDialog fileDialog = new OpenFileDialog() { Filter = "Text Files (.txt)|*.txt" };
- fileDialog.ShowDialog();
- if (!File.Exists(fileDialog.FileName))
- {
- Console.WriteLine("Selected file does not exist anymore.");
- }
- else
- {
- string line = String.Empty;
- char[] delimiters = new char[] { ' ' };
- int outputCnt = 0;
- StreamReader file = new StreamReader(fileDialog.FileName);
- while (((line = file.ReadLine()) != null) && (line.Length != 0))
- {
- line = String.Join(" ", line.Split(delimiters, StringSplitOptions.RemoveEmptyEntries));
- for (int i = 0; i < line.Length; i++)
- {
- ++outputCnt;
- Console.Write(line[i]);
- if (((outputCnt % 30 == 0) && (i != (line.Length - 1))) || (i == line.Length - 1))
- {
- Console.Write("\n");
- outputCnt = 0;
- }
- }
- }
- }
- Console.WriteLine("\nPress 'Enter' to exit.");
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement