Sams Teach Yourself .Net in 21 Days
- Table of Contents
- Copyright
- About the Author
- About the Technical Editor
- Acknowledgments
- We Want to Hear from You
- Introduction
- Week 1: At a Glance
- Day 1. Introduction to the Microsoft .NET Framework
- Day 2. Introduction to Visual Studio .NET
- Day 3. Writing Windows Forms Applications
- Day 4. Deploying Windows Forms Applications
- Day 5. Writing ASP.NET Applications
- Day 6. Deploying ASP.NET Applications
- Day 7. Exceptions, Debugging, and Tracing
- Week 1. In Review
- Week 2: At a Glance
- Day 8. Core Language Concepts in Visual Basic .NET and C#
- Day 9. Using Namespaces in .NET
- Day 10. Accessing Data with ADO.NET
- Day 11. Understanding Visual Database Tools
- Day 12. Accessing XML in .NET
- Day 13. XML Web Services in .NET
- Day 14. Components and .NET
- Week 2. In Review
- Week 3: At a Glance
- Day 15. Writing International Applications
- Day 16. Using Macros in Visual Studio .NET
- Day 17. Automating Visual Studio .NET
- Day 18. Using Crystal Reports
- Day 19. Understanding Microsoft Application Center Test
- Day 20. Using Visual SourceSafe
- Day 21. Object Role Modeling with Visio
- Week 3. In Review
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.
Day 10. Accessing Data with ADO.NET | Next Section

Account Sign In
View your cart