我试图做一些非常简单的事情,但是对于powershell来说,我很难搞清楚到底出了什么问题:
PS C:\Windows\system32> $directoryMaker = New-Object [System.IO.Directory]::CreateDirectory("C:\test")
New-Object : Cannot find type [[System.IO.Directory]::CreateDirectory]: make sure the assembly containing this type is loaded.
At line:1 char:19
+ $directoryMaker = New-Object [System.IO.Directory]::CreateDirectory("C:\test")
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidType: (:) [New-Object], PSArgumentException
+ FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand发布于 2013-09-16 12:17:29
试着:
$directoryMaker = [System.IO.Directory]::CreateDirectory("C:\test")在本例中,您使用的是static method ( CreateDirectory(string s) ),然后不需要实例化[System.IO.Directory]对象来引用该方法本身创建的新文件夹。
https://stackoverflow.com/questions/18827701
复制相似问题