Question
Challenge: Document Description: Save a text document to disk based on a name and content provided by the user. Purpose: This application provides experience with
Challenge: Document
Description: Save a text document to disk based on a name and content provided by the user.
Purpose: This application provides experience with user input and interaction in the Console, writing files to disk, working with exceptions, and writing programs in C#/.NET.
Requirements:
Project Name: Document Target Platform: Console Programming Language: C#
This program is to display the name of the app Document followed by a blank line, prompt the user for the name and content for a document, save the document to the current directory, and display a message if it was successful or unsuccessful based on a specification provided. The filename of the document is the name provided by the user with .txt appended to it.
When the program runs:
- Display Document followed by a blank line.
- Prompt the user for the name of the document.
- Prompt the user for the content that is to be in the document.
- Append .txt to the name and use it as the file name.
- Save the content to a file in the current directory.
- If an exception occurs, output the exception message and exit.
- If an exception does not occur, output [filename] was successfully saved. The document contains [count] characters. and exit. [filename] and [count] are placeholders for the filename of the document and the number of characters it contains.
Note that the requirements say the file is to be saved in the current directory. This means you can use just the file name as the path for the file. If you do that, the file will be saved in the current directory for the application. When I created the project and called it Document, a directory called Document was created that contains Document.sln and another directory called Document. The Document directory inside of the project is the current directory when the application runs and is where you will find the files that are saved.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started