New features in version 2.0 with common classes in the. NET Framework

Source: Internet
Author: User
Tags decrypt file system new features root directory
In the last article "browsing." NET Framework 2.0 type library new common features in the article I mainly listed a few new common main parts, this article as a summary of some commonly used in the expansion of some common classes recently in the use of C # 2.0 found several new features, said improper place please correct. 1. Exception exception base class at 2.0, the exception base class adds the Data property, the prototype is as follows, public virtual IDictionary Data {get;} It can be seen that it implements the IDictionary interface, which is used to store the custom information of the exception, thus thinking of the exceptionmanagement In the block, the NameValueCollection class member is added to the baseapplicationexception to have that feature, and exception is the source of the new data attribute? 2. File increases the decryption encryption function to protect the files using the new encryption and decryption method of filename. In the View tab of the Folder Options menu in the Windows2003 System window, you can see that the encrypted file color will be different by selecting the check box (which should also have relevant options in the XP or 2000 system) for displaying the encrypted or compressed NTFS file in color. The specific method is defined below, public static void Encrypt (string path); Encrypt public static void Decrypt (string path);//Decrypt the encryption, the file becomes green, and if the file is not authorized to other users, then the file cannot be accessed when other users log on. Click on the encrypted file property to get more information about the encryption. 3. The DriveInfo class DriveInfo class provides information about the system drive, which is a new class under. NET 2.0 that can be drivers = driveinfo.getdrives () through driveinfo[];

Indicates the amount of available free spaces on a drive. (quotas taken into account)
Gets the name of the file system, such as NTFS or FAT32.
Gets the drive type.
Gets information on whether or not the drive is ready.
Gets the name of the drive.
Gets the root directory of the drive.
Gets the total amount of free spaces available on a drive.
Gets the total size of storage spaces on the drive.
Gets and sets the volume label of the drive.

The Volumelabel above is read-write and the other properties are readonly. When used, it is generally necessary to determine whether the IsReady property is true, and if it is not, then access to other properties will cause an exception, as well as the need to be aware of permission access when the thread is being prepared. The DriveType enumeration is also added under. NET 2.0.

Member name
Description
CDRom
The drive is a CD ROM device.
Fixed
The drive is a fixed disk. (Fixed drive)
Network
The drive is a network drive. (Network Drive)
Norootdirectory
The drive does not have a root directory. (Drives without root)
Ram
The drive is a RAM disk. (RAM Flash memory)
Removable
The drive is a removable storage device. (Removable Storage device)
Unknown
The type of drive is unknown. (Unknown device type)

Use Directory.getlogicaldrives () in version 1.1 to get the drive. Of course, using WMI can also achieve all of these functions. 4. The System.Windows.Forms.Menu class adds the Tag property in 2.0 so that the MenuItem inherited from it also contains the property, just as the Treenode.tag property can hold various objects. 5. The console class is significantly enhanced consle adds a lot of functionality, including setting the appearance size and color of the console form, setting, moving the inside cursor, setting the buffer, determining whether the keyboard's specific keys are turned on, and so on. An example like Console.readkey () and its overloaded methods will be useful. The above features are written for the. NET Framework 2.0 Beta, and there may be some changes after the formal version comes out.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.