欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

PowerShell中文件對(duì)象的屬性方法總結(jié)

 更新時(shí)間:2014年08月01日 08:56:12   投稿:junjie  
這篇文章主要介紹了PowerShell中文件對(duì)象的屬性方法總結(jié),本文使用ps中的Get-Member語(yǔ)句輸出了關(guān)于文件對(duì)象的屬性和方法,需要的朋友可以參考下

本文介紹一個(gè)PowerShell中文件對(duì)象有哪些屬性,知道了這些屬性對(duì)于我們更好的對(duì)文件進(jìn)行操作是非常重要的。

PowerShell是一個(gè)面向?qū)ο蟮哪_本語(yǔ)言,在PowerShell中,所有的都是對(duì)象,文件也是對(duì)象。既然是對(duì)象,那肯定有屬性。PowerShell中的文件對(duì)象,其實(shí)就是.NET中的System.IO.FileInfo類的實(shí)例。我們要查看完整的PowerShell文件對(duì)象的屬性,其實(shí)不需要去翻MSDN,然后把System.IO.FileInfo類的屬性找出來(lái),那樣太麻煩了,而且貌似在PowerShell中,并不能完全按照.NET框架中提供的信息來(lái)操作。

在這里,小編介紹給大家個(gè)一個(gè)很簡(jiǎn)單的獲取文件對(duì)象屬性的方法,那就是Get-Member。且看下面的示例:

復(fù)制代碼 代碼如下:

PS C:\Users\splaybow> Get-Item d:\1.txt | Get-Member -MemberType property

   TypeName: System.IO.FileInfo

Name              MemberType Definition
----              ---------- ----------
Attributes        Property   System.IO.FileAttributes Attributes {get;set;}
CreationTime      Property   System.DateTime CreationTime {get;set;}
CreationTimeUtc   Property   System.DateTime CreationTimeUtc {get;set;}
Directory         Property   System.IO.DirectoryInfo Directory {get;}
DirectoryName     Property   System.String DirectoryName {get;}
Exists            Property   System.Boolean Exists {get;}
Extension         Property   System.String Extension {get;}
FullName          Property   System.String FullName {get;}
IsReadOnly        Property   System.Boolean IsReadOnly {get;set;}
LastAccessTime    Property   System.DateTime LastAccessTime {get;set;}
LastAccessTimeUtc Property   System.DateTime LastAccessTimeUtc {get;set;}
LastWriteTime     Property   System.DateTime LastWriteTime {get;set;}
LastWriteTimeUtc  Property   System.DateTime LastWriteTimeUtc {get;set;}
Length            Property   System.Int64 Length {get;}
Name              Property   System.String Name {get;}


在上面這個(gè)例子中,我們使用Get-Item獲取到一個(gè)文件對(duì)象。然后在管道之后,使用Get-Member,把文件對(duì)象的所有屬性全部都列了出來(lái)。其實(shí)這些屬性都很好理解,大家一看屬性名稱就知道它表示文件的哪方面內(nèi)容。

關(guān)于PowerShell中文件的屬性,本文就介紹這么多,希望對(duì)您有所幫助,謝謝!   

相關(guān)文章

最新評(píng)論