Question: Hello in C# please complete, Assignment 1 7 - 1 Work with a text file In this exercise, you'll add code to an Inventory Maintenance

Hello in C# please complete, Assignment 17-1 Work with a text file
In this exercise, you'll add code to an Inventory Maintenance app that reads data from and writes data to a text file.
1. Open the InventoryMaintenance project in the ExtraStarts \(\backslash \mathrm{Ch}17\backslash \)
InventoryMaintenanceText directory, and display the code for the InventoryDB class.
2. Add code to the GetItems () method that creates a StreamReader object with a FileStream object for the InventoryItems.txt file that's included in the project. (The Path constant contains the path to this file.) The file should be opened if it exists or created if it doesn't exist, and it should be opened for reading only.
3. Add code that reads each record of the text file, stores the fields, which are separated by pipe characters, in an InventoryItem object, and adds the object to the List object. Then, close the StreamReader object.
4. Add code to the SaveItems() method that creates a StreamWriter object with a FileStream object for the InventoryItems.txt file. The file should be created if it doesn't exist or overwritten if it does exist, and it should be opened for writing only.
5. Add code that writes each InventoryItem object in the Listobject to the text file, separating the fields with pipe characters. Then, close the StreamWriter object.
6. Test the app to be sure it works correctly.
7. Update the GetItems() and SaveItems() methods to use using declarations to automatically close the StreamReader and StreamWriter objects. Then, delete the statements that explicitly close these objects.
8. Test the app again to be sure it works correctly.
Hello in C# please complete, Assignment 1 7 - 1

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!