01.
$code
= @"
02.
using System;
03.
using System.IO;
04.
using System.Text;
05.
06.
public
class
Program
07.
{
08.
public
static
void Main()
09.
{
10.
Console.WriteLine(Environment.CurrentDirectory);
11.
12.
string path = @
"text-input-all.ps1"
;
13.
if
( File.Exists(path) )
14.
{
15.
Console.WriteLine(
"text-input-all.ps1 は存在しています"
);
16.
}
17.
18.
19.
Encoding Enc = Encoding.GetEncoding(932);
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
try
30.
{
31.
using (StreamReader ReadFile =
new
StreamReader(path, Enc))
32.
{
33.
34.
string Text = ReadFile.ReadToEnd();
35.
36.
37.
ReadFile.Close();
38.
39.
Console.WriteLine(Text);
40.
}
41.
42.
}
43.
catch (Exception ex)
44.
{
45.
Console.WriteLine(ex.Message);
46.
}
47.
48.
Console.ReadLine();
49.
}
50.
}
51.
"@
52.
53.
Add-Type -Language CSharp -TypeDefinition
$code
54.
55.
[Program]::Main()