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

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

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

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

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

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

復制代碼 代碼如下:

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;}


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

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

相關(guān)文章

最新評論