国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

使用.net framework中常用類在2.0版中的新功能

2024-07-10 12:58:59
字體:
來源:轉載
供稿:網友
在上一篇《瀏覽.net framework 2.0 類型庫中新增的常用功能》一文中我主要列了幾個新增的常用主件,本文作為小結主要針對一些常用類的擴展來講最近在使用c# 2.0 的時候發現的幾個新特征,講得不當之處請網友指正。 1.exception異常基類在2.0下,exception基類增加了data屬性,原型如下,public virtual idictionary data {get;}可見其實現了idictionary接口,用來存儲異常的自定義信息,由此想到在exceptionmanagement block中通過繼承增加namevaluecollection類成員來使baseapplicationexception具有該項功能,exception新增data屬性的靈感來源于此? 2.file增加解密加密功能使用file的新增加密解密方法來保護文件。在windows2003系統窗口的文件夾選項菜單的查看選項卡中選中用彩色顯示加密或壓縮的ntfs文件復選框(在xp或2000系統里應該也有相關的選項)就可以看到被加密的文件顏色會不一樣。具體方法定義如下,public static void encrypt(     string  path ); //加密 public static void decrypt(    string  path );//解密加密后,文件就會變成綠色,如果該文件沒有授權給其他用戶,那在其他用戶登錄時就無法訪問該文件。點擊加密文件屬性可以得到加密的更多信息。 3.driveinfo類driveinfo類提供系統驅動器的信息,是.net 2.0下新增的類,可以通過driveinfo[] drivers = driveinfo.getdrives();得到驅動信息,如:

availablefreespace 
indicates the amount of available free space on a drive.(配額考慮在內)
driveformat 
gets the name of the file system, such as ntfs or fat32.
drivetype 
gets the drive type.
isready 
gets information on whether or not the drive is ready.
name 
gets the name of the drive.
rootdirectory 
gets the root directory of the drive.
totalfreespace 
gets the total amount of free space available on a drive.
totalsize 
gets the total size of storage space on the drive.
volumelabel 
gets and sets the volume label of the drive.

 上面的volumelabel是可讀寫的,其他屬性是只讀的。在使用時一般需先判斷isready屬性是否為true,如果沒有準備好,那訪問其他屬性就會發生異常,還有需要注意在編程時是否有權限訪問。drivetype枚舉也是在.net 2.0下新增的,

member name
description
cdrom
the drive is a cd rom device.
fixed
the drive is a fixed disk.(固定磁盤驅動器)
network
the drive is a network drive.(網絡驅動器)
norootdirectory
the drive does not have a root directory.(不含根目錄的驅動器)
ram
the drive is a ram disk.(ram閃存)
removable
the drive is a removable storage device.(可移動存儲設備)
unknown
the type of drive is unknown.(未知設備類型)

 在1.1版中使用directory.getlogicaldrives();來得到驅動器。當然使用wmi也可以實現上述所有功能。 4.system.windows.forms.menu類在2.0中增加了tag屬性,這樣從它繼承的menuitem也就包含了該屬性,就像treenode.tag屬性可以保存各種對象。 5.console類明顯得到增強consle增加了很多功能,包括設置控制臺窗體的外觀大小和顏色,還可以設置、移動里面的光標,設置緩沖區,判斷鍵盤的那些特定鍵是否開啟等等。舉個例子像console.readkey ()以及它的重載方法將會很有用。 以上特征是我針對.net framework 2.0 beta 2來寫的,在正式版出來后也許會有些改動。
  • 本文來源于網頁設計愛好者web開發社區http://www.html.org.cn收集整理,歡迎訪問。
  • 發表評論 共有條評論
    用戶名: 密碼:
    驗證碼: 匿名發表
    主站蜘蛛池模板: 广南县| 桦甸市| 勐海县| 浑源县| 高清| 博罗县| 夏邑县| 炉霍县| 奉新县| 滨海县| 吐鲁番市| 赤峰市| 泸州市| 高清| 库伦旗| 松潘县| 古田县| 九台市| 台中市| 湘乡市| 黄浦区| 白山市| 丹寨县| 广昌县| 柞水县| 旅游| 长顺县| 托克逊县| 临邑县| 承德县| 石门县| 湘乡市| 南充市| 饶平县| 克什克腾旗| 通城县| 汕头市| 桃园县| 隆昌县| 英德市| 化州市|