File (System.IO)

0.0(0)
Studied by 0 people
call kaiCall Kai
Locked
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/29

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 4:16 AM on 8/14/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

30 Terms

1
New cards

File

A static class in System.IO that provides methods for creating, copying, moving, deleting, opening, reading, and writing files. Domain: C# → .NET → System.IO → Files

2
New cards

File.Exists(path)

Determines whether a file exists at the specified path and returns false rather than throwing for many invalid or inaccessible path situations.

3
New cards

File.Create(path)

Creates or overwrites a file at the specified path and returns a FileStream for accessing it.

4
New cards

File.Delete(path)

Deletes the specified file; if the file does not exist, the method does not throw merely because it is absent.

5
New cards

File.Copy(source, destination)

Copies an existing file to a new location and does not overwrite an existing destination file by default.

6
New cards

File.Copy(source, destination, overwrite)

Copies a file while allowing the caller to specify whether an existing destination file may be overwritten.

7
New cards

File.Move(source, destination)

Moves a file from one path to another.

8
New cards

File.Replace(source, destination, backup)

Replaces the contents of one file with another file and can create a backup of the replaced file.

9
New cards

File.ReadAllText(path)

Opens a text file, reads all of its text into a string, and closes the file.

10
New cards

File.ReadAllText(path, encoding)

Reads all text from a file using the specified character encoding.

11
New cards

File.ReadAllLines(path)

Reads all lines of a text file into a string array, with one array element per line.

12
New cards

File.ReadLines(path)

Returns an enumerable sequence of lines that are read lazily rather than loading all lines into an array at once.

13
New cards

File.ReadAllBytes(path)

Reads the entire contents of a file into a byte array.

14
New cards

File.WriteAllText(path, contents)

Creates or overwrites a file and writes the specified text to it.

15
New cards

File.WriteAllText(path, contents, encoding)

Creates or overwrites a file and writes text using the specified character encoding.

16
New cards

File.WriteAllLines(path, contents)

Creates or overwrites a file and writes a sequence of text lines to it.

17
New cards

File.WriteAllBytes(path, bytes)

Creates or overwrites a file and writes the specified byte array to it.

18
New cards

File.AppendAllText(path, contents)

Opens or creates a file and appends text to its end without replacing the existing contents.

19
New cards

File.AppendAllLines(path, contents)

Appends a sequence of lines to a file, creating the file if necessary.

20
New cards

File.OpenRead(path)

Opens an existing file for reading and returns a FileStream.

21
New cards

File.OpenWrite(path)

Opens an existing file or creates a new file for writing and returns a FileStream.

22
New cards

File.Open(path, mode)

Opens a file using the specified FileMode and returns a FileStream.

23
New cards

File.Open(path, mode, access, share)

Opens a file while explicitly controlling creation/opening behavior, permitted access, and sharing behavior.

24
New cards

File.GetCreationTime(path)

Gets the creation date and time of the specified file.

25
New cards

File.GetLastWriteTime(path)

Gets the date and time when the specified file was last written to.

26
New cards

File.GetLastAccessTime(path)

Gets the date and time when the specified file was last accessed.

27
New cards

File.SetLastWriteTime(path, time)

Sets the last-write date and time of the specified file.

28
New cards

File.Encrypt(path)

Encrypts a file using operating-system file encryption where the API and underlying platform support it.

29
New cards

File.Decrypt(path)

Decrypts a file previously encrypted through supported operating-system file encryption.

30
New cards

File vs FileInfo

File provides static operations using file paths directly, whereas FileInfo represents a particular file as an object with instance properties and methods.