Question #39275

Sharon is the owner of a supermarket. She sells a large variety of grocery items through her
supermarket, such as toothpastes, soaps, and other household items.
Currently, Sharon keeps track of the different items available in stock manually. However, the
number of items sold through the supermarket has increased tremendously. Therefore, Sharon
spends long periods of time to keep track of each and every item.
To ensure easy and effective management of the stock details, Sharon decides to use a
customized application. For this purpose, she approaches the AlphaSoft Inc., which is a software
development organization. The management of AlphaSoft Inc. asks Hayley, a software developer,
to handle the application development requirements of Sharon.
Hayley conducts a meeting with Sharon and notes the following requirements for the application:
Sharon does not have the budget to implement Relational Database Management System
(RDBMS). However, she needs the stock details to be available at all times. Therefore, the
application needs to store the inventory details persistently on Sharon's computer.
The application should allow Sharon to perform the following tasks:
Add details of new items to the stock.
Modify the details of existing items.
View the last modified date of the stock details file.
Question:
Sharon decides to develop the application using C#. Analyze the preceding scenario and answer
the following questions:
Which classes of the .NET Framework should Hayley use to ensure that the stock details are
available to Sharon at all times? Justify your answer along with reasons. [6 Marks]
Which class of the .NET Framework should Hayley use to enable Sharon to view the file
extension of the stock details file? Describe any four properties of the selected class. [4 Marks]

Expert's answer

Answer on Question#39275, Programming, C#

1) Question: Which classes of the .NET Framework should Hayley use to ensure that the stock details are available to Sharon at all times? Justify your answer along with reasons.

Answer: There are several main classes to ensure that the files are available. One of them is "File" class from "System.IO" namespace. It contains "bool Exists(string path)" method that allows to ensure that the file exists. It returns logic value "true" or "false" and takes 1 string argument with the path to appropriate file.

The next class is "FileInfo" from "System.IO" namespace. It also has the same "bool Exists(string path)" method. This method duplicates method from the previous class.

The difference is that in the second case you need to create an object of the FileInfo class and then call "Exists" method from created object. In the "File" class "Exists" method is static. It means that it can be called from class name: System.IO.File.Exists(string path). So these two classes would help Hayley to ensure that the stock details are available to Sharon at all times.

2) Question: Which class of the .NET Framework should Hayley use to enable Sharon to view the file extension of the stock details file?

Answer: To do this Hayley should use "FileInfo" class from the "System.IO" namespace. It contains useful property "Extension" that returns string value with the file extension. To use this property Hayley must follow the next steps:


System.IO.FileInfo object_name = new System.IO.FileInfo(string file_path);
object_name.Extension


that will return the extension of the file that was declared in the previous step.

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS