Subjective Short Answer41. Write a program that prompts a user for a filename and tests the file's existence. If the file exists, display the file creation time. If it does not exist, display a message.

What will be an ideal response?

The program should be similar to the following:
using static System.Console;
using System.IO;
class FileStatistics
{
static void Main()
{
string fileName;
Write("Enter a filename >> ");
fileName = ReadLine();
if(File.Exists(fileName))
{
Writeline ("File exists");
WriteLine("File was created " +
File.GetCreationTime(fileName));
WriteLine("File was last accessed " +
File.GetLastAccessTime(fileName));
WriteLine("File was last written to " +
File.GetLastWrittenTime(fileName));
}
else
{
WriteLine("File does not exist");
}
}
}

Computer Science & Information Technology

You might also like to view...

What is displayed on the console when running the following program?

``` public class Test { public static void main(String[] args) { try { p(); System.out.println("After the method call"); } catch (RuntimeException ex) { System.out.println("RuntimeException"); } catch (Exception ex) { System.out.println("Exception"); } } static void p() throws Exception { try { String s = "5.6"; Integer.parseInt(s); // Cause a NumberFormatException int i = 0; int y = 2 / i; System.out.println("Welcome to Java"); } catch (RuntimeException ex) { System.out.println("RuntimeException"); } catch (Exception ex) { System.out.println("Exception"); } } } ``` a. The program displays RuntimeException twice. b. The program displays Exception twice. c. The program displays RuntimeException followed by After the method call. d. The program displays Exception followed by RuntimeException. e. The program has a compile error.

Computer Science & Information Technology

The ____ Tool selects a rectangular or square portion of a document window.?

A. ?Rectangular Marquee B. ?Elliptical Marquee C. ?Single Row Marquee D. ?Single Column Marquee

Computer Science & Information Technology