小编sil*_*rip的帖子

如何从 System.IO.File 调用访问 PSDrive?

我正在编写 ac# cmdlet,它将文件从一个位置复制到另一个位置(类似于 rsync)。它甚至支持 ToSession 和 FromSession。

我希望它能够与使用文件系统提供程序的 PSDrive 一起使用,但它当前会从 System.IO.File.GetAttributes("psdrive:\path") 引发错误

我真的很想在 PSDrive 上使用来自 System.IO 的调用。

像 copy-item 这样的东西是如何做到这一点的?

我已经执行了从 c# 访问 PSDrive 的搜索,但没有返回任何结果。

这相当于我的代码

new-psdrive -name mydrive -psprovider filesystem  -root \\aserver\ashare -Credential domain\user
$attributes=[system.io.file]::GetAttributes("mydrive:\path\")
Run Code Online (Sandbox Code Playgroud)

回报

Exception calling "GetAttributes" with "1" argument(s): "The given path's format is not supported."
Run Code Online (Sandbox Code Playgroud)

c# powershell new-psdrive

4
推荐指数
1
解决办法
1100
查看次数

标签 统计

c# ×1

new-psdrive ×1

powershell ×1