PowerShell是一个面向对象的脚本语言,在PowerShell中,所有的都是对象,文件也是对象。既然是对象,那肯定有属性。PowerShell中的文件对象,其实就是.NET中的System.IO.FileInfo类的实例。我们要查看完整的PowerShell文件对象的属性,其实不需要去翻MSDN,然后把System.IO.FileInfo类的属性找出来,那样太麻烦了,而且貌似在PowerShell中,并不能完全按照.NET框架中提供的信息来操作。
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;}