Search notes:

System.IO.File (static class)

System.IO.File only has static methods and allows for generic file related operations in a file system.
In contrast, System.IO.FileInfo represents a specific file.

Methods

AppendAllLines()
AppendAllLinesAsync()
AppendAllText()
AppendAllTextAsync()
AppendText()
Copy()
Create()
CreateSymbolicLink()
CreateText()
Decrypt()
Delete()
Encrypt()
Exists() Checks if a file exists.
GetAttributes()
GetCreationTime()
GetCreationTimeUtc()
GetLastAccessTime()
GetLastAccessTimeUtc()
GetLastWriteTime()
GetLastWriteTimeUtc()
Move()
Open()
OpenHandle()
OpenRead()
OpenText()
OpenWrite()
ReadAllBytes()
ReadAllBytesAsync()
ReadAllLines()
ReadAllLinesAsync()
ReadAllText() Slurps the content of an entire file.
ReadAllTextAsync()
ReadLines()
Replace()
ResolveLinkTarget()
SetAttributes()
SetCreationTime()
SetCreationTimeUtc()
SetLastAccessTime()
SetLastAccessTimeUtc()
SetLastWriteTime()
SetLastWriteTimeUtc()
WriteAllBytes() Creates a new or overwrites an existing file, writes the specified byte array to the file, and then closes the file.
WriteAllBytesAsync()
WriteAllLines()
WriteAllLinesAsync()
WriteAllText()
WriteAllTextAsync()
Why is there no WriteAllBytes() method?

Exists

The method Exists checks if a file exists.
Compare with the test-path cmdLet.

ReadAllText

ReadAllText slurps the content of an entire file.

Concatenating multiple files

The following example concatentas multiple files in PowerShell:
PS: C:\> $a = [IO.File]::ReadAllText("$pwd\a.txt")
PS: C:\> $b = [IO.File]::ReadAllText("$pwd\b.txt")
PS: C:\> $c = [IO.File]::ReadAllText("$pwd\c.txt")
PS: C:\> [IO.File]::WriteAllText("$pwd\concatenated" , $a)
PS: C:\> [IO.File]::AppendAllText("$pwd\concatenated", $b)
PS: C:\> [IO.File]::AppendAllText("$pwd\concatenated", $c)
Of course, the canonical way would be something like the following, but is tends to mess things because it sometimes writes BOMs:
get-content a.txt,b.txt,c.txt | set-content concatenated.txt

Index