Reputation: 2318
I have a console app that takes hundreds of small files, puts them into a temporary DataTable and then copies the data to a single StreamWriter. That works fine.
However, the console output continually adds "..." during the StreamWriter copy process, which is a bit annoying.
Is there any way to turn this off, or just replace it with something else, suck as a blinking "."?
Here's a cut down version of the code being used:
Console.WriteLine("Writing to TA_{0}", fileType);
var streamMaster = new StreamWriter(Settings.WorkingDirectory + "TA_" + fileType, true);
streamMaster.Flush();
foreach (var tempFile in filesList)
{
var isZipped = tempFile.Contains(".gz");
var dtTempFile = InternalUtils.GetTable(tempFile, isZipped);
foreach (DataRow row in dtTempFile.Rows)
{
if(dtTempFile.Rows.IndexOf(row) != 0) streamMaster.WriteLine(String.Join(",", row.ItemArray));
}
streamMaster.Write(dtTempFile.Copy());
dtTempFile.Dispose();
}
streamMaster.Close();
streamMaster.Dispose();
Console.WriteLine("TA_{0} Complete", fileType);
The output looks a lot like this:
Any ideas?
Upvotes: 0
Views: 74
Reputation: 5430
For progress you could show Console animation
for the purpose. Which deals with few symbol like |
/
slash etc. You could set cursor position to spin it like animation.
Console.WriteLine("Writing to TA_{0}", fileType);
using(var streamMaster = new StreamWriter(Settings.WorkingDirectory + "TA_" + fileType, true))
{
streamMaster.Flush();
int counter = 0;
foreach (var tempFile in filesList)
{
ShowAnimation(++counter);
var isZipped = tempFile.Contains(".gz");
var dtTempFile = InternalUtils.GetTable(tempFile, isZipped);
foreach (DataRow row in dtTempFile.Rows)
{
if(dtTempFile.Rows.IndexOf(row) != 0)
streamMaster.WriteLine(String.Join(",", row.ItemArray));
}
streamMaster.Write(dtTempFile.Copy());
dtTempFile.Dispose();
}
}
Console.WriteLine("TA_{0} Complete", fileType);
ShowAnimation Method:
public void ShowAnimation (int counter)
{
switch (counter % 4)
{
case 0: Console.Write("/"); break;
case 1: Console.Write("-"); break;
case 2: Console.Write("\\"); break;
case 3: Console.Write("|"); break;
}
Console.SetCursorPosition(Console.CursorLeft - 1, Console.CursorTop);
}
Upvotes: 1
Reputation: 2318
Turns out there was a function several layers in that did this...
If m_intRecord Mod 1000 = 0 Then
Console.Write(".")
End If
I must have completely overlooked it! Whoops!
Upvotes: 0