What should you do?

Domain.com has asked you to develop an application that displays the properties for all Domain.com’s network drives.
The information generated by this application will be utilized by Domain.com’s network administrators to verify client setups.
You need to ensure that these requirements are fully satisfied.
What should you do?

Domain.com has asked you to develop an application that displays the properties for all Domain.com’s network drives.
The information generated by this application will be utilized by Domain.com’s network administrators to verify client setups.
You need to ensure that these requirements are fully satisfied.
What should you do?

A.
Use the following code:
public void EnumerateNetworkDrives (){
foreach (Drive netDrive in Drive.GetDrives()){
if (netDrive.DriveType == DriveType.Network)
Console.WriteLine (“{0} ({1}) : {2} bytes”, netDrive.Name, netDrive.VolumeLabel,netDrive.TotalSize);
}
}

B.
Use the following code:
public void EnumerateNetworkDrives (){
foreach (DriveInfo netDrive in DriveInfo.GetDrives()){
Console.WriteLine (“{0} ({1}) : {2} bytes”, netDrive.Name, netDrive.VolumeLabel,netDrive.TotalSize);
}
}

C.
Use the following code:
public void EnumerateNetworkDrives (){
foreach (DriveInfo netDrive in DriveInfo.GetDrives()){
if (netDrive.DriveType == DriveType.Network)
Console.WriteLine (“{0} ({1}) : {2} bytes”, netDrive.Name, netDrive.VolumeLabel,netDrive.TotalSize);
}
}

D.
Use the following code:
public void EnumerateNetworkDrives (){
foreach (DriveInfo netDrive in DriveInfo.GetDrives(DriveType.Network)){
Console.WriteLine (“{0} ({1}) : {2} bytes”, netDrive.Name, netDrive.VolumeLabel,netDrive.TotalSize);
}
}

Explanation:
The GetDrives method is invoked and returns an array of DriveInfo objects representing the available drives.
The DriveType property is used to verify that the netDrive variable is a network drive. The DriveType property returns a DriveType enumeration value that can be Network, Fixed, CDRom, or Removable.
If the DriveType property is DriveType.Network, then the Console.WriteLine method displays the Name, VolumeLabel
and TotalSize properties of the DriveInfo object to the console.
Incorrect Answers:
A: You should not use the code that uses the Disk class because there is no such class in the System.IO namespace.
B D: You should not use the code fragments that do not retrieve the DriveType property of the DriveInfo object because there is no such signature for the GetDrives method and no such method as GetNetworkDrives.



Leave a Reply 1

Your email address will not be published. Required fields are marked *