21
In C#, which class provides information about a specific file?
A)
FileData
B)
FileInformation
C)
FileDetail
D)
FileInfo
Answer & Solution
Answer: Option
D
22
In C#, which method is used to open an existing text file for reading?
A)
File.WriteText()
B)
File.CreateText()
C)
File.ReadText()
D)
File.OpenText()
Answer & Solution
Answer: Option
D
23
What is the purpose of the File.SetAttributes() method in C#?
A)
Retrieves the attributes of a specified file or directory
B)
Deletes the attributes of a specified file or directory
C)
Sets the attributes of a specified file or directory
D)
Clears the attributes of a specified file or directory
Answer & Solution
Answer: Option
C
24
Which class in C# is used to perform synchronous and asynchronous read and write operations to a file in a managed application?
A)
TextFile
B)
FileStream
C)
FileHandler
D)
None of the above
Answer & Solution
Answer: Option
B
25
In C#, which method is used to write a string to a text file?
A)
WriteLine()
B)
WriteString()
C)
Write()
D)
WriteText()
Answer & Solution
Answer: Option
C
26
In C#, what happens if you attempt to read from a file that does not exist using File.OpenRead() method?
A)
FileNotFoundException is thrown
B)
DirectoryNotFoundException is thrown
C)
FileLoadException is thrown
D)
IOException is thrown
Answer & Solution
Answer: Option
A
27
What is the purpose of the File.Create() method in C#?
A)
Renames a file
B)
Deletes a file
C)
Opens an existing file for reading
D)
Creates a new file or overwrites an existing file
Answer & Solution
Answer: Option
D
28
In C#, which class represents a writer that provides a fast, non-cached, forward-only way of generating sequences of characters from streams of bytes?
A)
TextWriter
B)
BinaryWriter
C)
StreamWriter
D)
CharWriter
Answer & Solution
Answer: Option
C
29
What is the purpose of the File.WriteAllText() method in C#?
A)
Appends text to the end of a file
B)
Writes the specified string to a file, overwriting the file if it already exists
C)
Reads the contents of a file into an array of bytes
D)
None of the above
Answer & Solution
Answer: Option
B
30
In C#, what method is used to create a new file if it does not exist, or overwrite the existing file if it does exist?
A)
File.Open()
B)
File.CreateText()
C)
File.Create()
D)
File.OpenWrite()
Answer & Solution
Answer: Option
C