PS C:\WINDOWS\winsxs> dir *.xml | select basename
BaseName
migration
返回的是对象(文件、或目录)。
PS C:\WINDOWS\winsxs> dir *.xml | select basename | gm
TypeName:Selected.System.IO.FileInfo
Name MemberType Definition
—- ———- ———-
Equals Method bool Equals(System.Object obj)
GetHashCode Method int GetHashCode()
GetType Method type GetType()
ToString Method string ToString()
BaseName NoteProperty System.String BaseName=migration
有时,我们需要的不是对象,而是字符串。可以用下面的命令:
PS C:\WINDOWS\winsxs> ( dir *.xml | select basename ).basename
migration
PS C:\WINDOWS\winsxs> ( dir *.xml | select basename ).basename | gm
TypeName:System.String
Name MemberType Definition
—- ———- ———-
Clone Method System.Object Clone(), System.Object IClonea
CompareTo Method int CompareTo(System.Object value), int Comp
Contains Method bool Contains(string value)
…