Repository navigation
Expand file tree
/
Copy pathProgram.cs
More file actions
64 lines (62 loc) · 1.99 KB
/
Copy pathProgram.cs
File metadata and controls
64 lines (62 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WaitForExitHangsTest
{
class Program
{
const string Path = @"F:\Migration\Users\Public\Documents\ECMA\Ecma-334.pdf";
static void Main(string[] args)
{
Process OurProcess = Process.GetCurrentProcess();
Console.Error.WriteLine($"Test process is {OurProcess.Id} {OurProcess.ProcessName}");
FileInfo fi = null;
try { fi = new FileInfo(Path); }
catch (Exception ex)
{
Console.Error.WriteLine("Input FileInfo error: " + ex.Message);
return;
}
if (!fi.Exists)
{
Console.Error.WriteLine("Input File does not exist");
return;
}
//
StreamReader stream = null;
try { stream = new StreamReader(Path); }
catch (Exception ex)
{
Console.Error.WriteLine("Input open error: " + ex.Message);
return;
}
//System.Windows.Forms.MessageBox.Show("Begin");
Console.SetIn(stream);
int datasize = 0;
try
{
string record = Console.ReadLine();
while (record != null)
{
datasize += record.Length + 2;
record = Console.ReadLine();
Console.WriteLine(record);
}
}
catch (Exception ex)
{
Console.Error.WriteLine($"Error: {ex.Message}");
return;
}
string counts = $"{fi.Length} {datasize}";
Console.WriteLine(counts);
Console.Error.WriteLine(counts);
//System.Windows.Forms.MessageBox.Show(counts);
//Console.WriteLine("Test line");
}
}
}