68 249
Assignments Done
99%
Successfully Done
In November 2018

Answer to Question #41252 in C# for Rabijyoti

Question #41252
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.
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:
- Create an object of the “FileInfo” class:
System.IO.FileInfo object_name = new System.IO.FileInfo(string file_path);
- Use “Extension” property:
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!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions