主頁 > 知識庫 > PowerShell中文件對象的屬性方法總結(jié)

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

熱門標(biāo)簽:新鄭電銷機器人一個月多少錢 電話機器人公司招聘 印臺區(qū)呼叫中心外呼系統(tǒng) 萬全縣地圖標(biāo)注app 莫拉克電梯系統(tǒng)外呼怎么設(shè)置 騰訊地圖標(biāo)注中心怎么標(biāo)注 地圖標(biāo)注的圖案 六寸地圖標(biāo)注點怎么刪除 如何根據(jù)經(jīng)緯度百度地圖標(biāo)注

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

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

在這里,小編介紹給大家個一個很簡單的獲取文件對象屬性的方法,那就是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;}


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

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

標(biāo)簽:臨汾 天水 疫苗接種 汕頭 南昌 湘潭 喀什 襄陽

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《PowerShell中文件對象的屬性方法總結(jié)》,本文關(guān)鍵詞  PowerShell,中,文件,對象,的,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《PowerShell中文件對象的屬性方法總結(jié)》相關(guān)的同類信息!
  • 本頁收集關(guān)于PowerShell中文件對象的屬性方法總結(jié)的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章