using System;
using System.IO;
using System.Text;
using System.Collections;
namespace DocSplitter
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
string inputPath = @"c:\temp\input.txt";
string outputPath = @"c:\temp\output.txt";
// if file doesn't exist bale.
if (!File.Exists(inputPath))
{
Console.WriteLine("You are stupid, put a file at location: " + inputPath + " or this program wont work!\n");
return;
}
// Open the stream and read it back.
using (StreamReader srIn = new StreamReader(inputPath))
{
ArrayList words = new ArrayList();
try
{
string line;
while((line = srIn.ReadLine()) != null)
{
foreach (string word in line.Split())
{
// adding words to list so i can iterate over it.
words.Add(word);
}
}
while(words.Contains(""))
{
words.Remove("");
}
words.TrimToSize();
using(StreamWriter srOut = new StreamWriter(outputPath))
{
int index = 0;
while(words.Count != 0)
{
if(words.Count > 70)
{
index = 70;
srOut.Write(((string)words[index]) + " ");
words.RemoveAt(index);
words.TrimToSize();
}
else
{
index = 71 % words.Count;
srOut.Write(((string)words[index]) + " ");
words.RemoveAt(index);
words.TrimToSize();
}
}
srOut.Flush();
}
}
catch (Exception e)
{
Console.Write("Something bad happened OMGWTFBBQ\n");
}
}
return;
}
}
}
using System.IO;
using System.Text;
using System.Collections;
namespace DocSplitter
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
string inputPath = @"c:\temp\input.txt";
string outputPath = @"c:\temp\output.txt";
// if file doesn't exist bale.
if (!File.Exists(inputPath))
{
Console.WriteLine("You are stupid, put a file at location: " + inputPath + " or this program wont work!\n");
return;
}
// Open the stream and read it back.
using (StreamReader srIn = new StreamReader(inputPath))
{
ArrayList words = new ArrayList();
try
{
string line;
while((line = srIn.ReadLine()) != null)
{
foreach (string word in line.Split())
{
// adding words to list so i can iterate over it.
words.Add(word);
}
}
while(words.Contains(""))
{
words.Remove("");
}
words.TrimToSize();
using(StreamWriter srOut = new StreamWriter(outputPath))
{
int index = 0;
while(words.Count != 0)
{
if(words.Count > 70)
{
index = 70;
srOut.Write(((string)words[index]) + " ");
words.RemoveAt(index);
words.TrimToSize();
}
else
{
index = 71 % words.Count;
srOut.Write(((string)words[index]) + " ");
words.RemoveAt(index);
words.TrimToSize();
}
}
srOut.Flush();
}
}
catch (Exception e)
{
Console.Write("Something bad happened OMGWTFBBQ\n");
}
}
return;
}
}
}