Question #38074

As part of her business activities, Sharon has created a large number of files and folders.

Whenever she needs to view the details of the files stored in a folder, Sharon browses to the folder

using Windows Explorer. However, she finds it cumbersome to browse to each individual folder to

view the desired details. Therefore, she asks Hayley to modify the application to accept the name

of a folder and display the following details of the files located in the folder:

• File name

• File size

• File creation date

Expert's answer

Answer on Question#38074- Programming, C#

1. As part of her business activities, Sharon has created a large number of files and folders. Whenever she needs to view the details of the files stored in a folder, Sharon browses to the folder using Windows Explorer. However, she finds it cumbersome to browse to each individual folder to view the desired details. Therefore, she asks Hayley to modify the application to accept the name of a folder and display the following details of the files located in the folder:

- File name

- File size

- File creation date

Solution.

Complete code below:


protected void Button1_Click(object sender, EventArgs e)
{
    if (FileUpload1.HasFile)
    {
        FileUpload1.SaveAs("c://temp" + FileUpload1.FileName);
        String name = FileUpload1.FileName;
        Label1.Text = name;
        Label2.Text = ("file Uploaded successfully to c:/Temp");
        FileInfo file = new FileInfo("c://" + FileUpload1.FileName);
        Response.Write("Location : " + file.FullName + "<br/>" + "Size : " + file.Length + "<br/>" + "Created : " + file.CreationTime + "<br/>" + "Modified : " + file.LastWriteTime + "<br/>" + "Accessed : " + file.LastAccessTime + "<br/>" + "Attributes : " + file.Attributes + "<br/>" + "Extension : " + file.Extension + "<br/>");
    }
    else
    {
        Label2.Text = ("No files uploaded. Check Again.");
    }
}

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