π Top 15 Udemy Courses (80-90% Discount): My Udemy Courses - Ramesh Fadatare — All my Udemy courses are real-time and project oriented courses.
▶️ Subscribe to My YouTube Channel (178K+ subscribers): Java Guides on YouTube
▶️ For AI, ChatGPT, Web, Tech, and Generative AI, subscribe to another channel: Ramesh Fadatare on YouTube
1. Which namespace is commonly used for file handling in C#?
Answer:
Explanation:
The System.IO namespace contains types for handling files and data streams, making it the primary namespace used for file handling in C#.
2. How do you create a text file in C#?
Answer:
Explanation:
The File.CreateText method is used to create a new text file in C#. It returns a StreamWriter.
3. What class is used to read text from a file in C#?
Answer:
Explanation:
StreamReader is a class in the System.IO namespace used for reading text from files.
4. Which method is used to write text to a file in C#?
Answer:
Explanation:
File.WriteAllLines() writes a string array to a file, with each string as a line. For appending or continuous writing, StreamWriter can be used.
5. How do you append text to an existing file in C#?
Answer:
Explanation:
File.AppendAllText method appends text to the end of an existing file.
6. What is the purpose of the FileStream class in C#?
Answer:
Explanation:
FileStream is used for reading from and writing to files as streams of bytes, providing control over byte positions in files.
7. Which method checks for the existence of a file in C#?
Answer:
Explanation:
File.Exists method is used to check if a file exists at a specified path.
8. How do you copy a file in C#?
Answer:
Explanation:
The File.Copy method is used to copy a file to a new location.
9. How do you delete a file in C#?
Answer:
Explanation:
File.Delete method is used to delete a specified file.
10. Which class is used to read and write binary files in C#?
Answer:
Explanation:
BinaryReader and BinaryWriter are used for reading and writing binary data to and from files.
11. How do you move a file in C#?
Answer:
Explanation:
The File.Move method is used to move a file to a new location.
12. What is the use of the Path class in C#?
Answer:
Explanation:
The Path class in the System.IO namespace provides methods for manipulating file and directory paths.
13. What exception is commonly associated with file handling errors in C#?
Answer:
Explanation:
IOException is a general exception that occurs when an I/O error happens during file handling operations.
14. How can you read all lines of a text file into a string array in C#?
Answer:
Explanation:
File.ReadAllLines reads all the lines of the specified file into a string array.
15. Which method is used to read all text from a file in one go in C#?
Answer:
Explanation:
File.ReadAllText reads all text from the file and returns it as a single string.
My Top and Bestseller Udemy Courses. The sale is going on with a 70 - 80% discount. The discount coupon has been added to each course below:
Build REST APIs with Spring Boot 4, Spring Security 7, and JWT
[NEW] Learn Apache Maven with IntelliJ IDEA and Java 25
ChatGPT + Generative AI + Prompt Engineering for Beginners
Spring 7 and Spring Boot 4 for Beginners (Includes 8 Projects)
Available in Udemy for Business
Building Real-Time REST APIs with Spring Boot - Blog App
Available in Udemy for Business
Building Microservices with Spring Boot and Spring Cloud
Available in Udemy for Business
Java Full-Stack Developer Course with Spring Boot and React JS
Available in Udemy for Business
Build 5 Spring Boot Projects with Java: Line-by-Line Coding
Testing Spring Boot Application with JUnit and Mockito
Available in Udemy for Business
Spring Boot Thymeleaf Real-Time Web Application - Blog App
Available in Udemy for Business
Master Spring Data JPA with Hibernate
Available in Udemy for Business
Spring Boot + Apache Kafka Course - The Practical Guide
Available in Udemy for Business
Comments
Post a Comment
Leave Comment