Workshop


Quiz

1.

Under what hive should you store a user's confirmation information in the Registry?

2.

What is the full object/method used to create a key in the CURRENTUSER hive of the Registry?

3.

What are the two methods used to delete a key from the Registry, and what is the difference between the two?

4.

What classes do you use to write and read text files?

5.

What method of the StreamReader class do you use to read the entire contents of a text file at once?

6.

What happens if you attempt to open a file that doesn't exist with the StreamReader class?

Answers

1.

You should store user configuration in the HKEY_CURRENT_USER hive.

2.

Microsoft.Win32.Registry.CurrentUser.CreateSubKey().

3.

The method DeleteSubKey() deletes a key, but only if there are no subkeys for the specified key. The method DeleteSubKeyTree() deletes a key and any subkeys of the specified key.

4.

The StreamWriter class is used to write to a text file, whereas the StreamReader class is used to read data from a text file.

5.

The ReadToEnd() method.

6.

An exception is thrown.

Exercises

1.

Every toolbar item should have a corresponding menu item. Create a menu item on the Tools menu for displaying the log. While you're at it, create one for viewing the file properties to match the toolbar item you created in the previous hour.

2.

Create a button on the Log Viewer form called btnClearLog. Change the text of the button to Clear. When the user clicks the button, delete the log file from the hard drive and close the Log Viewer form.




Sams Teach Yourself Microsoft Visual C# 2005 in 24 Hours, Complete Starter Kit
Sams Teach Yourself Visual C# 2005 in 24 Hours, Complete Starter Kit
ISBN: 0672327406
EAN: 2147483647
Year: N/A
Pages: 248
Authors: James Foxall

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net