Exercises
Create a new ASP.NET application using the same code as the I/O application to enable you to select directories and list their contents from the browser. An application like this could be used to list Web site contents and allow users to download files, or as an administration tool for listing files and directories and creating new file and directories.
Look up the FileAttributes enumeration in the .NET Framework SDK. This enumeration gives the attributes of files on the operating system. Next, write a simple console application that uses the GetFiles method of the Directory class, and write the code that returns the attributes of the files in the root of your C drive. You can refer to Listing 9.5, where you used the GetFileSystemEntries method to retrieve files and folders.
Create a new Windows Forms application that enables you to set the LastAccessTime and LastWriteTime for files on your file system. To accomplish this, add a TreeView control, two DateTimePicker controls, and a CommandButton to the default Form1 of the new application that you create. The idea is to get and set the values of the LastAccessTime and LastWriteTime for files in the file system. Here''''s the code you need to write:
Using the methods of the File and Directory class, fill the TreeView with the contents of your C drive.
Each time you click a node in the TreeView, set the DateTimePicker values with the current LastAccessTime and LastWriteTime values.
In the click event for the Set New Times button, add code to reset the LastAccessTime and LastWriteTime for the selected file.
Your form should look like Figure 9.17.
Figure 9.17. Sample of the Exercise 3 application.
